frostfs-api-go/v2/session/string.go
Leonard Lyubich 616b4b71a1 [#310] *: Implement string converters for enumerations
Implement `String` / `FromString` method pair in all levels of enum
definitions. From now `String()` returns canonical protojson-compatible
values.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-06-23 10:24:32 +03:00

47 lines
1.1 KiB
Go

package session
import (
session "github.com/nspcc-dev/neofs-api-go/v2/session/grpc"
)
// String returns string representation of ObjectSessionVerb.
func (x ObjectSessionVerb) String() string {
return ObjectSessionVerbToGRPCField(x).String()
}
// FromString parses ObjectSessionVerb from a string representation.
// It is a reverse action to String().
//
// Returns true if s was parsed successfully.
func (x *ObjectSessionVerb) FromString(s string) bool {
var g session.ObjectSessionContext_Verb
ok := g.FromString(s)
if ok {
*x = ObjectSessionVerbFromGRPCField(g)
}
return ok
}
// String returns string representation of ContainerSessionVerb.
func (x ContainerSessionVerb) String() string {
return ContainerSessionVerbToGRPCField(x).String()
}
// FromString parses ContainerSessionVerb from a string representation.
// It is a reverse action to String().
//
// Returns true if s was parsed successfully.
func (x *ContainerSessionVerb) FromString(s string) bool {
var g session.ContainerSessionContext_Verb
ok := g.FromString(s)
if ok {
*x = ContainerSessionVerbFromGRPCField(g)
}
return ok
}