2024-04-22 06:51:20 +00:00
|
|
|
package object
|
|
|
|
|
|
|
|
import (
|
2024-10-07 14:20:25 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/object"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/refs"
|
2024-04-22 06:51:20 +00:00
|
|
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ECChunk object.ECChunk
|
|
|
|
|
|
|
|
func (c *ECChunk) SetID(id oid.ID) {
|
|
|
|
objV2 := new(refs.ObjectID)
|
|
|
|
id.WriteToV2(objV2)
|
|
|
|
c.ID = *objV2
|
|
|
|
}
|
|
|
|
|
|
|
|
// ToV2 converts ECChunk to v2 ECChunk message.
|
|
|
|
//
|
|
|
|
// Nil ECChunk converts to nil.
|
|
|
|
func (c *ECChunk) ToV2() *object.ECChunk {
|
|
|
|
return (*object.ECChunk)(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewECChunkFromV2(v2 *object.ECChunk) *ECChunk {
|
|
|
|
return (*ECChunk)(v2)
|
|
|
|
}
|
|
|
|
|
|
|
|
type ECInfo object.ECInfo
|
|
|
|
|
|
|
|
// NewECInfoFromV2 wraps v2 ECInfo message to ECInfo.
|
|
|
|
//
|
|
|
|
// Nil object.ECInfo converts to nil.
|
|
|
|
func NewECInfoFromV2(v2 *object.ECInfo) *ECInfo {
|
|
|
|
return (*ECInfo)(v2)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewECInfo creates and initializes blank ECInfo.
|
|
|
|
func NewECInfo() *ECInfo {
|
|
|
|
return NewECInfoFromV2(new(object.ECInfo))
|
|
|
|
}
|
|
|
|
|
|
|
|
// ToV2 converts ECInfo to v2 ECInfo message.
|
|
|
|
//
|
|
|
|
// Nil ECInfo converts to nil.
|
|
|
|
func (s *ECInfo) ToV2() *object.ECInfo {
|
|
|
|
return (*object.ECInfo)(s)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ECInfo) Marshal() ([]byte, error) {
|
|
|
|
return (*object.ECInfo)(s).StableMarshal(nil), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ECInfo) Unmarshal(data []byte) error {
|
|
|
|
return (*object.ECInfo)(s).Unmarshal(data)
|
|
|
|
}
|
|
|
|
|
|
|
|
// MarshalJSON implements json.Marshaler.
|
|
|
|
func (s *ECInfo) MarshalJSON() ([]byte, error) {
|
|
|
|
return (*object.ECInfo)(s).MarshalJSON()
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalJSON implements json.Unmarshaler.
|
|
|
|
func (s *ECInfo) UnmarshalJSON(data []byte) error {
|
|
|
|
return (*object.ECInfo)(s).UnmarshalJSON(data)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ECInfo) AddChunk(chunk ECChunk) {
|
|
|
|
s.Chunks = append(s.Chunks, *chunk.ToV2())
|
|
|
|
}
|