frostfs-api-go-pogpp/tombstone/convert.go
Leonard Lyubich 25da5d2e13 Add v2 version to go module name
Replace all elements from `v2` to root directory.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-11-17 15:29:33 +03:00

41 lines
849 B
Go

package tombstone
import (
"github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/nspcc-dev/neofs-api-go/v2/rpc/grpc"
"github.com/nspcc-dev/neofs-api-go/v2/rpc/message"
tombstone "github.com/nspcc-dev/neofs-api-go/v2/tombstone/grpc"
)
func (s *Tombstone) ToGRPCMessage() grpc.Message {
var m *tombstone.Tombstone
if s != nil {
m = new(tombstone.Tombstone)
m.SetMembers(refs.ObjectIDListToGRPCMessage(s.members))
m.SetExpirationEpoch(s.exp)
m.SetSplitId(s.splitID)
}
return m
}
func (s *Tombstone) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tombstone.Tombstone)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
var err error
s.members, err = refs.ObjectIDListFromGRPCMessage(v.GetMembers())
if err != nil {
return err
}
s.exp = v.GetExpirationEpoch()
s.splitID = v.GetSplitId()
return nil
}