forked from TrueCloudLab/frostfs-node
[#30] core/object: Make Object constructors similar to RawObject
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
2975b61abd
commit
0a6130a924
1 changed files with 15 additions and 7 deletions
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue