[#30] core/object: Make Object constructors similar to RawObject

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-09-16 15:27:48 +03:00 committed by Alex Vanin
parent 2975b61abd
commit 0a6130a924

View file

@ -28,17 +28,25 @@ func (o *Object) Address() *object.Address {
return nil return nil
} }
// FromV2 converts v2 Object message to Object. // NewFromV2 constructs Object instance from v2 Object message.
func FromV2(oV2 *objectV2.Object) *Object { func NewFromV2(obj *objectV2.Object) *Object {
if oV2 == nil {
return nil
}
return &Object{ return &Object{
Object: object.NewFromV2(oV2), 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())
}
// FromBytes restores Object from binary format. // FromBytes restores Object from binary format.
func FromBytes(data []byte) (*Object, error) { func FromBytes(data []byte) (*Object, error) {
o, err := object.FromBytes(data) o, err := object.FromBytes(data)