2021-11-08 10:04:45 +00:00
|
|
|
package object
|
|
|
|
|
|
|
|
import (
|
2023-03-07 11:20:03 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/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
|
|
|
|
}
|