forked from TrueCloudLab/frostfs-sdk-go
[#64] object: move package from neofs-api-go
Also, remove deprecated method. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
bdb99877f6
commit
39d3317ef6
28 changed files with 3268 additions and 0 deletions
45
object/object.go
Normal file
45
object/object.go
Normal file
|
@ -0,0 +1,45 @@
|
|||
package object
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/object"
|
||||
)
|
||||
|
||||
// Object represents v2-compatible NeoFS object that provides
|
||||
// a convenient interface for working in isolation
|
||||
// from the internal structure of an object.
|
||||
//
|
||||
// Object allows to work with the object in read-only
|
||||
// mode as a reflection of the immutability of objects
|
||||
// in the system.
|
||||
type Object struct {
|
||||
*rwObject
|
||||
}
|
||||
|
||||
// NewFromV2 wraps v2 Object message to Object.
|
||||
func NewFromV2(oV2 *object.Object) *Object {
|
||||
return &Object{
|
||||
rwObject: (*rwObject)(oV2),
|
||||
}
|
||||
}
|
||||
|
||||
// New creates and initializes blank Object.
|
||||
//
|
||||
// Works similar as NewFromV2(new(Object)).
|
||||
func New() *Object {
|
||||
return NewFromV2(new(object.Object))
|
||||
}
|
||||
|
||||
// ToV2 converts Object to v2 Object message.
|
||||
func (o *Object) ToV2() *object.Object {
|
||||
if o != nil {
|
||||
return (*object.Object)(o.rwObject)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalHeaderJSON marshals object's header
|
||||
// into JSON format.
|
||||
func (o *Object) MarshalHeaderJSON() ([]byte, error) {
|
||||
return (*object.Object)(o.rwObject).GetHeader().MarshalJSON()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue