frostfs-api-go-pogpp/pkg/netmap/clause.go
Leonard Lyubich 8c1afc6bab [#189] sdk/netmap: Refactor Clause enum
Replace alias to v2 type Clause with v2-compatible implementation.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-11-06 09:28:50 +03:00

54 lines
1 KiB
Go

package netmap
import (
"github.com/nspcc-dev/neofs-api-go/v2/netmap"
)
// Clause is an enumeration of selector modifiers
// that shows how the node set will be formed.
type Clause uint32
const (
_ Clause = iota
// ClauseSame is a selector modifier to select only nodes having the same value of bucket attribute.
ClauseSame
// ClauseDistinct is a selector modifier to select nodes having different values of bucket attribute.
ClauseDistinct
)
// ClauseFromV2 converts v2 Clause to Clause.
func ClauseFromV2(c netmap.Clause) Clause {
switch c {
default:
return 0
case netmap.Same:
return ClauseSame
case netmap.Distinct:
return ClauseDistinct
}
}
// ToV2 converts Clause to v2 Clause.
func (c Clause) ToV2() netmap.Clause {
switch c {
default:
return netmap.UnspecifiedClause
case ClauseDistinct:
return netmap.Distinct
case ClauseSame:
return netmap.Same
}
}
func (c Clause) String() string {
switch c {
default:
return "UNSPECIFIED"
case ClauseDistinct:
return "DISTINCT"
case ClauseSame:
return "SAME"
}
}