[#168] refs: Implement binary/JSON encoders/decoders on ContainerID

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-13 16:07:32 +03:00 committed by Alex Vanin
parent 7289ff6c64
commit c0f3ac51d4
6 changed files with 103 additions and 4 deletions

View file

@ -76,6 +76,17 @@ func (c *ContainerID) StableSize() int {
return proto.BytesSize(containerIDValField, c.val)
}
func (c *ContainerID) Unmarshal(data []byte) error {
m := new(refs.ContainerID)
if err := goproto.Unmarshal(data, m); err != nil {
return err
}
*c = *ContainerIDFromGRPCMessage(m)
return nil
}
func (o *ObjectID) StableMarshal(buf []byte) ([]byte, error) {
if o == nil {
return []byte{}, nil