diff --git a/pkg/object/splitinfo.go b/pkg/object/splitinfo.go index 1f7494d2..600b87b5 100644 --- a/pkg/object/splitinfo.go +++ b/pkg/object/splitinfo.go @@ -47,3 +47,16 @@ func (s *SplitInfo) Link() *ID { func (s *SplitInfo) SetLink(v *ID) { (*object.SplitInfo)(s).SetLink(v.ToV2()) } + +func (s *SplitInfo) Marshal(b ...[]byte) ([]byte, error) { + var buf []byte + if len(b) > 0 { + buf = b[0] + } + + return (*object.SplitInfo)(s).StableMarshal(buf) +} + +func (s *SplitInfo) Unmarshal(data []byte) error { + return (*object.SplitInfo)(s).Unmarshal(data) +} diff --git a/pkg/object/splitinfo_test.go b/pkg/object/splitinfo_test.go index 854defe8..8f07313c 100644 --- a/pkg/object/splitinfo_test.go +++ b/pkg/object/splitinfo_test.go @@ -29,6 +29,17 @@ func TestSplitInfo(t *testing.T) { require.Equal(t, s, newS) }) + + t.Run("marshal and unmarshal", func(t *testing.T) { + data, err := s.Marshal() + require.NoError(t, err) + + newS := object.NewSplitInfo() + + err = newS.Unmarshal(data) + require.NoError(t, err) + require.Equal(t, s, newS) + }) } func generateID() *object.ID { diff --git a/v2/object/marshal.go b/v2/object/marshal.go index 9f91b67d..b8147379 100644 --- a/v2/object/marshal.go +++ b/v2/object/marshal.go @@ -629,6 +629,17 @@ func (s *SplitInfo) StableSize() (size int) { return size } +func (s *SplitInfo) Unmarshal(data []byte) error { + m := new(object.SplitInfo) + if err := goproto.Unmarshal(data, m); err != nil { + return err + } + + *s = *SplitInfoFromGRPCMessage(m) + + return nil +} + func (r *GetRequestBody) StableMarshal(buf []byte) ([]byte, error) { if r == nil { return []byte{}, nil