forked from TrueCloudLab/frostfs-api-go
52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
|
package status
|
||
|
|
||
|
// details for WrongMagicNumber code.
|
||
|
const (
|
||
|
// DetailIDCorrectMagic is an identifier of details with correct network magic
|
||
|
// which can be attached to WrongMagicNumber code.
|
||
|
DetailIDCorrectMagic = iota
|
||
|
)
|
||
|
|
||
|
// NumberOfParameters returns number of network parameters.
|
||
|
func (x *Status) NumberOfDetails() int {
|
||
|
if x != nil {
|
||
|
return len(x.GetDetails())
|
||
|
}
|
||
|
|
||
|
return 0
|
||
|
}
|
||
|
|
||
|
// IterateDetails iterates over details of the Status.
|
||
|
// Breaks iteration on f's true return.
|
||
|
//
|
||
|
// Handler must not be nil.
|
||
|
func (x *Status) IterateDetails(f func(*Status_Detail) bool) {
|
||
|
if x != nil {
|
||
|
for _, detail := range x.GetDetails() {
|
||
|
if f(detail) {
|
||
|
break
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// ResetDetails empties the detail list.
|
||
|
func (x *Status) ResetDetails() {
|
||
|
if x != nil {
|
||
|
x.Details = x.Details[:0]
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// AppendDetails appends the list of details to the Status.
|
||
|
func (x *Status) AppendDetails(ds ...*Status_Detail) {
|
||
|
if x != nil {
|
||
|
x.Details = append(x.Details, ds...)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// SetStatusDetails sets Detail list of the Status.
|
||
|
func SetStatusDetails(dst *Status, ds []*Status_Detail) {
|
||
|
dst.ResetDetails()
|
||
|
dst.AppendDetails(ds...)
|
||
|
}
|