From 0b9ddd10f8375e56d6555eda2c953e641e6269b5 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 16 Sep 2020 14:23:09 +0300 Subject: [PATCH] [#145] sdk/object: Implement Object deserialization function Signed-off-by: Leonard Lyubich --- pkg/object/object.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/object/object.go b/pkg/object/object.go index e447be59..9de49a73 100644 --- a/pkg/object/object.go +++ b/pkg/object/object.go @@ -37,3 +37,14 @@ func (o *Object) ToV2() *object.Object { return nil } + +// FromBytes restores Object instance from a binary representation. +func FromBytes(data []byte) (*Object, error) { + oV2 := new(object.Object) + + if err := oV2.StableUnmarshal(data); err != nil { + return nil, err + } + + return NewFromV2(oV2), nil +}