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
|
|
|
}
|
|
|
|
|
|
|
|
// String returns string representation of Type.
|
|
|
|
//
|
|
|
|
// String mapping:
|
|
|
|
// * TypeTombstone: TOMBSTONE;
|
|
|
|
// * TypeStorageGroup: STORAGE_GROUP;
|
2022-02-15 05:41:03 +00:00
|
|
|
// * TypeLock: LOCK;
|
2021-11-08 10:04:45 +00:00
|
|
|
// * TypeRegular, default: REGULAR.
|
|
|
|
func (t Type) String() string {
|
|
|
|
return t.ToV2().String()
|
|
|
|
}
|
|
|
|
|
|
|
|
// FromString parses Type from a string representation.
|
|
|
|
// It is a reverse action to String().
|
|
|
|
//
|
|
|
|
// Returns true if s was parsed successfully.
|
|
|
|
func (t *Type) FromString(s string) bool {
|
|
|
|
var g object.Type
|
|
|
|
|
|
|
|
ok := g.FromString(s)
|
|
|
|
|
|
|
|
if ok {
|
|
|
|
*t = TypeFromV2(g)
|
|
|
|
}
|
|
|
|
|
|
|
|
return ok
|
|
|
|
}
|