2020-09-16 12:03:57 +00:00
|
|
|
package object
|
|
|
|
|
|
|
|
import (
|
|
|
|
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
2021-11-10 07:08:33 +00:00
|
|
|
"github.com/nspcc-dev/neofs-sdk-go/object"
|
2020-09-16 12:03:57 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// RawObject represents the raw NeoFS object.
|
|
|
|
//
|
|
|
|
// RawObject inherits RawObject type from NeoFS SDK.
|
|
|
|
// It is used to implement some useful methods and functions
|
|
|
|
// for convenient processing of a raw object by a node.
|
|
|
|
type RawObject struct {
|
|
|
|
*object.RawObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewRawFromV2 constructs RawObject instance from v2 Object message.
|
|
|
|
func NewRawFromV2(obj *objectV2.Object) *RawObject {
|
|
|
|
return &RawObject{
|
|
|
|
RawObject: object.NewRawFromV2(obj),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewRawFrom constructs RawObject instance from NeoFS SDK RawObject.
|
|
|
|
func NewRawFrom(obj *object.RawObject) *RawObject {
|
|
|
|
return &RawObject{
|
|
|
|
RawObject: obj,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-22 14:54:11 +00:00
|
|
|
// NewRawFromObject wraps Object instance to RawObject.
|
|
|
|
func NewRawFromObject(obj *Object) *RawObject {
|
|
|
|
return NewRawFrom(object.NewRawFrom(obj.SDK()))
|
|
|
|
}
|
|
|
|
|
2020-09-16 12:03:57 +00:00
|
|
|
// NewRaw constructs blank RawObject instance.
|
|
|
|
func NewRaw() *RawObject {
|
|
|
|
return NewRawFrom(object.NewRaw())
|
|
|
|
}
|
|
|
|
|
|
|
|
// SDK converts RawObject to NeoFS SDK RawObject instance.
|
|
|
|
func (o *RawObject) SDK() *object.RawObject {
|
|
|
|
if o != nil {
|
|
|
|
return o.RawObject
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Object converts RawObject to read-only Object instance.
|
|
|
|
func (o *RawObject) Object() *Object {
|
|
|
|
if o != nil {
|
|
|
|
return &Object{
|
|
|
|
Object: o.RawObject.Object(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2020-09-22 14:54:43 +00:00
|
|
|
|
|
|
|
// CutPayload returns RawObject w/ empty payload.
|
|
|
|
//
|
|
|
|
// Changes of non-payload fields affect source object.
|
|
|
|
func (o *RawObject) CutPayload() *RawObject {
|
|
|
|
if o != nil {
|
|
|
|
return &RawObject{
|
|
|
|
RawObject: o.RawObject.CutPayload(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|