frostfs-api-go/pkg/object/raw.go
Leonard Lyubich 8c3f8268b9 [#130] sdk: Define object types
Define Object type that represents the immutable NeoFS object. Define
RawObject type that provides interface for convenient construction of NeoFS
object.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-09-18 10:45:11 +03:00

53 lines
1.1 KiB
Go

package object
import (
"crypto/sha256"
"github.com/nspcc-dev/neofs-api-go/pkg/container"
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
)
// RawObject represents NeoFS object that provides
// a convenient interface to fill in the fields of
// an object in isolation from its internal structure.
type RawObject struct {
rwObject
}
func (o *RawObject) set(setter func()) {
o.fin = false
setter()
}
// SetContainerID sets object's container identifier.
func (o *RawObject) SetContainerID(v *container.ID) {
if o != nil {
o.set(func() {
o.cid = v
})
}
}
// SetOwnerID sets identifier of the object's owner.
func (o *RawObject) SetOwnerID(v *owner.ID) {
if o != nil {
o.set(func() {
o.ownerID = v
})
}
}
// SetPayloadChecksumSHA256 sets payload checksum as a SHA256 checksum.
func (o *RawObject) SetPayloadChecksumSHA256(v [sha256.Size]byte) {
if o != nil {
o.set(func() {
if o.payloadChecksum == nil {
o.payloadChecksum = new(refs.Checksum)
}
o.payloadChecksum.SetType(refs.SHA256)
o.payloadChecksum.SetSum(v[:])
})
}
}