2021-11-06 10:38:52 +00:00
|
|
|
package status
|
|
|
|
|
|
|
|
import (
|
2023-03-07 10:38:56 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message"
|
|
|
|
status "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/status/grpc"
|
|
|
|
protoutil "git.frostfs.info/TrueCloudLab/frostfs-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) {
|
2023-07-26 13:53:20 +00:00
|
|
|
if x == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2021-11-06 10:38:52 +00:00
|
|
|
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))
|
|
|
|
}
|