[#50] util: Use protowire for util/proto helpers

* Use methods to calculate size

Signed-off-by: Airat Arifullin a.arifullin@yadro.com
This commit is contained in:
Airat Arifullin 2023-08-02 16:53:47 +03:00 committed by Evgenii Stratonikov
parent 67b18d3550
commit 9a7b47d769
2 changed files with 26 additions and 50 deletions

View file

@ -6,6 +6,7 @@ import (
refs "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/grpc"
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message"
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/proto"
"google.golang.org/protobuf/encoding/protowire"
)
const (
@ -116,7 +117,7 @@ func (o *ObjectID) StableSize() int {
// ObjectIDNestedListMarshal writes protobuf repeated ObjectID field
// with fNum number to buf.
func ObjectIDNestedListMarshal(fNum int64, buf []byte, ids []ObjectID) (off int) {
prefix, _ := proto.NestedStructurePrefix(fNum)
prefix := protowire.EncodeTag(protowire.Number(fNum), protowire.BytesType)
for i := range ids {
off += binary.PutUvarint(buf[off:], prefix)