[#1214] *: Use single Object type in whole project

Remove `Object` and `RawObject` types from `pkg/core/object` package.
Use `Object` type from NeoFS SDK Go library everywhere. Avoid using the
deprecated elements.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-03-03 17:19:05 +03:00 committed by Alex Vanin
parent 19ad349b27
commit 7ccd1625af
100 changed files with 847 additions and 965 deletions

View file

@ -1,70 +1,18 @@
package object
import (
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
)
// Object represents the NeoFS object.
//
// Object inherits object type from NeoFS SDK.
// It is used to implement some useful methods and functions
// for convenient processing of an object by a node.
type Object struct {
*object.Object
}
// AddressOf returns address of the object.
func AddressOf(obj *object.Object) *addressSDK.Address {
if obj != nil {
addr := addressSDK.NewAddress()
addr.SetObjectID(obj.ID())
addr.SetContainerID(obj.ContainerID())
// Address returns address of the object.
func (o *Object) Address() *addressSDK.Address {
if o != nil {
aV2 := new(refs.Address)
aV2.SetObjectID(o.ID().ToV2())
aV2.SetContainerID(o.ContainerID().ToV2())
return addressSDK.NewAddressFromV2(aV2)
}
return nil
}
// SDK returns NeoFS SDK object instance.
func (o *Object) SDK() *object.Object {
if o != nil {
return o.Object
}
return nil
}
// NewFromV2 constructs Object instance from v2 Object message.
func NewFromV2(obj *objectV2.Object) *Object {
return &Object{
Object: object.NewFromV2(obj),
}
}
// NewFromSDK constructs Object instance from NeoFS SDK Object.
func NewFromSDK(obj *object.Object) *Object {
return &Object{
Object: obj,
}
}
// New constructs blank Object instance.
func New() *Object {
return NewFromSDK(object.New())
}
// GetParent returns parent object.
func (o *Object) GetParent() *Object {
if o != nil {
if par := o.Object.Parent(); par != nil {
return &Object{
Object: par,
}
}
return addr
}
return nil