forked from TrueCloudLab/frostfs-node
[#17] core/object: Implement Object and Address types
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
80f10dab7b
commit
edcaef8478
3 changed files with 105 additions and 9 deletions
35
pkg/core/object/address.go
Normal file
35
pkg/core/object/address.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package object
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
||||
)
|
||||
|
||||
type Address struct {
|
||||
*object.Address
|
||||
}
|
||||
|
||||
// MarshalStableV2 marshals Address to v2 binary format.
|
||||
func (a *Address) MarshalStableV2() ([]byte, error) {
|
||||
if a != nil {
|
||||
return a.ToV2().StableMarshal(nil)
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// AddressFromV2 converts v2 Address message to Address.
|
||||
func AddressFromV2(aV2 *refs.Address) (*Address, error) {
|
||||
if aV2 == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
a, err := object.AddressFromV2(aV2)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Address{
|
||||
Address: a,
|
||||
}, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue