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
|
|
|
|
)
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (x *Detail) StableMarshal(buf []byte) []byte {
|
2021-11-06 10:38:52 +00:00
|
|
|
if x == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2021-11-06 10:38:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
2022-04-05 08:24:34 +00:00
|
|
|
protoutil.BytesMarshal(detailValueFNum, buf[offset:], x.val)
|
2021-11-06 10:38:52 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2021-11-06 10:38:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
)
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (x *Status) StableMarshal(buf []byte) []byte {
|
2021-11-06 10:38:52 +00:00
|
|
|
if x == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2021-11-06 10:38:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, x.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
var offset int
|
2021-11-06 10:38:52 +00:00
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += protoutil.UInt32Marshal(statusCodeFNum, buf[offset:], CodeToGRPC(x.code))
|
|
|
|
offset += protoutil.StringMarshal(statusMsgFNum, buf[offset:], x.msg)
|
2021-11-06 10:38:52 +00:00
|
|
|
|
|
|
|
for i := range x.details {
|
2022-04-05 08:24:34 +00:00
|
|
|
offset += protoutil.NestedStructureMarshal(statusDetailsFNum, buf[offset:], &x.details[i])
|
2021-11-06 10:38:52 +00:00
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2021-11-06 10:38:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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))
|
|
|
|
}
|