diff --git a/pkg/object/raw.go b/pkg/object/raw.go index 2615530f..5ae3108f 100644 --- a/pkg/object/raw.go +++ b/pkg/object/raw.go @@ -110,6 +110,11 @@ func (o *RawObject) SetChildren(v ...*ID) { o.setChildren(v...) } +// SetSplitID sets split identifier for the split object. +func (o *RawObject) SetSplitID(v []byte) { + o.setSplitID(v) +} + // SetParentID sets identifier of the parent object. func (o *RawObject) SetParentID(v *ID) { o.setParentID(v) diff --git a/pkg/object/raw_test.go b/pkg/object/raw_test.go index 2aabca4f..f6e85a87 100644 --- a/pkg/object/raw_test.go +++ b/pkg/object/raw_test.go @@ -5,6 +5,7 @@ import ( "crypto/sha256" "testing" + "github.com/google/uuid" "github.com/nspcc-dev/neofs-api-go/pkg" "github.com/nspcc-dev/neofs-api-go/pkg/container" "github.com/nspcc-dev/neofs-api-go/pkg/owner" @@ -190,6 +191,19 @@ func TestRawObject_SetChildren(t *testing.T) { require.Equal(t, []*ID{id1, id2}, obj.Children()) } +func TestRawObject_SetSplitID(t *testing.T) { + obj := NewRaw() + + require.Nil(t, obj.SplitID()) + + splitID, err := uuid.New().MarshalBinary() + require.NoError(t, err) + + obj.SetSplitID(splitID) + + require.Equal(t, obj.SplitID(), splitID) +} + func TestRawObject_SetParent(t *testing.T) { obj := NewRaw() diff --git a/pkg/object/rw.go b/pkg/object/rw.go index e6be2e5c..0412f913 100644 --- a/pkg/object/rw.go +++ b/pkg/object/rw.go @@ -251,6 +251,21 @@ func (o *rwObject) setChildren(v ...*ID) { }) } +// SplitID return split identity of split object. If object is not split +// returns nil. +func (o *rwObject) SplitID() []byte { + return (*object.Object)(o). + GetHeader(). + GetSplit(). + GetSplitID() +} + +func (o *rwObject) setSplitID(id []byte) { + o.setSplitFields(func(split *object.SplitHeader) { + split.SetSplitID(id) + }) +} + // ParentID returns identifier of the parent object. func (o *rwObject) ParentID() *ID { return NewIDFromV2(