2021-11-06 10:38:52 +00:00
|
|
|
package status
|
|
|
|
|
|
|
|
import (
|
2021-11-17 09:35:56 +00:00
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/rpc/message"
|
2021-11-06 10:38:52 +00:00
|
|
|
status "github.com/nspcc-dev/neofs-api-go/v2/status/grpc"
|
2021-11-17 09:35:56 +00:00
|
|
|
protoutil "github.com/nspcc-dev/neofs-api-go/v2/util/proto"
|
2021-11-06 10:38:52 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
_ = iota
|
|
|
|
detailIDFNum
|
|
|
|
detailValueFNum
|
|
|
|
)
|
|
|
|
|
|
|
|
func (x *Detail) StableMarshal(buf []byte) ([]byte, error) {
|
|
|
|
if x == nil {
|
|
|
|
return []byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, x.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
var offset int
|
2021-11-06 10:38:52 +00:00
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += protoutil.UInt32Marshal(detailIDFNum, buf[offset:], x.id)
|
|
|
|
offset += protoutil.BytesMarshal(detailValueFNum, buf[offset:], x.val)
|
2021-11-06 10:38:52 +00:00
|
|
|
|
|
|
|
return buf, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *Detail) StableSize() (size int) {
|
|
|
|
size += protoutil.UInt32Size(detailIDFNum, x.id)
|
|
|
|
size += protoutil.BytesSize(detailValueFNum, x.val)
|
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *Detail) Unmarshal(data []byte) error {
|
|
|
|
return message.Unmarshal(x, data, new(status.Status_Detail))
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
_ = iota
|
|
|
|
statusCodeFNum
|
|
|
|
statusMsgFNum
|
|
|
|
statusDetailsFNum
|
|
|
|
)
|
|
|
|
|
|
|
|
func (x *Status) StableMarshal(buf []byte) ([]byte, error) {
|
|
|
|
if x == nil {
|
|
|
|
return []byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, x.StableSize())
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
offset, n int
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += protoutil.UInt32Marshal(statusCodeFNum, buf[offset:], CodeToGRPC(x.code))
|
2021-11-06 10:38:52 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += protoutil.StringMarshal(statusMsgFNum, buf[offset:], x.msg)
|
2021-11-06 10:38:52 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := range x.details {
|
2022-03-02 08:43:54 +00:00
|
|
|
n, err = protoutil.NestedStructureMarshal(statusDetailsFNum, buf[offset:], &x.details[i])
|
2021-11-06 10:38:52 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *Status) StableSize() (size int) {
|
|
|
|
size += protoutil.UInt32Size(statusCodeFNum, CodeToGRPC(x.code))
|
|
|
|
size += protoutil.StringSize(statusMsgFNum, x.msg)
|
|
|
|
|
|
|
|
for i := range x.details {
|
2022-03-02 08:43:54 +00:00
|
|
|
size += protoutil.NestedStructureSize(statusDetailsFNum, &x.details[i])
|
2021-11-06 10:38:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *Status) Unmarshal(data []byte) error {
|
|
|
|
return message.Unmarshal(x, data, new(status.Status))
|
|
|
|
}
|