git.frostfs.info/TrueCloudLab/frostfs-sdk-go@v0.0.0-20241022124111-5361f0ecebd3/object/type.go (about) 1 package object 2 3 import ( 4 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object" 5 ) 6 7 type Type object.Type 8 9 const ( 10 TypeRegular Type = iota 11 TypeTombstone 12 _ 13 TypeLock 14 ) 15 16 func (t Type) ToV2() object.Type { 17 return object.Type(t) 18 } 19 20 func TypeFromV2(t object.Type) Type { 21 return Type(t) 22 } 23 24 // String returns string representation of Type. 25 // 26 // String mapping: 27 // - TypeTombstone: TOMBSTONE; 28 // - TypeLock: LOCK; 29 // - TypeRegular, default: REGULAR. 30 func (t Type) String() string { 31 return t.ToV2().String() 32 } 33 34 // FromString parses Type from a string representation. 35 // It is a reverse action to String(). 36 // 37 // Returns true if s was parsed successfully. 38 func (t *Type) FromString(s string) bool { 39 var g object.Type 40 41 ok := g.FromString(s) 42 43 if ok { 44 *t = TypeFromV2(g) 45 } 46 47 return ok 48 }