2021-11-08 10:04:45 +00:00
|
|
|
package object
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/object"
|
|
|
|
)
|
|
|
|
|
2022-02-15 05:41:03 +00:00
|
|
|
type Type object.Type
|
2021-11-08 10:04:45 +00:00
|
|
|
|
|
|
|
const (
|
|
|
|
TypeRegular Type = iota
|
|
|
|
TypeTombstone
|
|
|
|
TypeStorageGroup
|
2022-02-15 05:41:03 +00:00
|
|
|
TypeLock
|
2021-11-08 10:04:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (t Type) ToV2() object.Type {
|
2022-02-15 05:41:03 +00:00
|
|
|
return object.Type(t)
|
2021-11-08 10:04:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TypeFromV2(t object.Type) Type {
|
2022-02-15 05:41:03 +00:00
|
|
|
return Type(t)
|
2021-11-08 10:04:45 +00:00
|
|
|
}
|
|
|
|
|
2023-04-19 10:33:35 +00:00
|
|
|
// EncodeToString returns string representation of Type.
|
2021-11-08 10:04:45 +00:00
|
|
|
//
|
|
|
|
// String mapping:
|
2022-08-24 14:17:40 +00:00
|
|
|
// - TypeTombstone: TOMBSTONE;
|
|
|
|
// - TypeStorageGroup: STORAGE_GROUP;
|
|
|
|
// - TypeLock: LOCK;
|
|
|
|
// - TypeRegular, default: REGULAR.
|
2023-04-19 10:33:35 +00:00
|
|
|
func (t Type) EncodeToString() string {
|
2021-11-08 10:04:45 +00:00
|
|
|
return t.ToV2().String()
|
|
|
|
}
|
|
|
|
|
2023-04-19 10:33:35 +00:00
|
|
|
// String implements fmt.Stringer.
|
|
|
|
//
|
|
|
|
// String is designed to be human-readable, and its format MAY differ between
|
|
|
|
// SDK versions. String MAY return same result as EncodeToString. String MUST NOT
|
|
|
|
// be used to encode ID into NeoFS protocol string.
|
|
|
|
func (t Type) String() string {
|
|
|
|
return t.EncodeToString()
|
|
|
|
}
|
|
|
|
|
|
|
|
// DecodeString parses Type from a string representation.
|
|
|
|
// It is a reverse action to EncodeToString().
|
2021-11-08 10:04:45 +00:00
|
|
|
//
|
|
|
|
// Returns true if s was parsed successfully.
|
2023-04-19 10:33:35 +00:00
|
|
|
func (t *Type) DecodeString(s string) bool {
|
2021-11-08 10:04:45 +00:00
|
|
|
var g object.Type
|
|
|
|
|
|
|
|
ok := g.FromString(s)
|
|
|
|
|
|
|
|
if ok {
|
|
|
|
*t = TypeFromV2(g)
|
|
|
|
}
|
|
|
|
|
|
|
|
return ok
|
|
|
|
}
|