2021-11-08 10:04:45 +00:00
|
|
|
package object
|
|
|
|
|
|
|
|
import (
|
2024-10-07 14:20:25 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/object"
|
2021-11-08 10:04:45 +00:00
|
|
|
)
|
|
|
|
|
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
|
2023-04-27 11:04:38 +00:00
|
|
|
_
|
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:
|
2022-08-24 14:17:40 +00:00
|
|
|
// - TypeTombstone: TOMBSTONE;
|
|
|
|
// - TypeLock: LOCK;
|
|
|
|
// - TypeRegular, default: REGULAR.
|
2021-11-08 10:04:45 +00:00
|
|
|
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
|
|
|
|
}
|