[#40] types: Generate StableMarshaler methods for refs

* Add plugin option for protogen in Makefile
* Fix the generator for the plugin in util/protogen
* Fix marshaler.go for refs

Signed-off-by: Airat Arifullin a.arifullin@yadro.com
This commit is contained in:
Airat Arifullin 2023-06-13 01:33:53 +03:00
parent 8266b31092
commit f0642d7f13
8 changed files with 343 additions and 191 deletions

View file

@ -2,6 +2,7 @@ package message
import (
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/grpc"
protoutil "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/proto"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)
@ -46,3 +47,13 @@ func UnmarshalJSON(m Message, data []byte, gm GRPCConvertedMessage) error {
return m.FromGRPCMessage(gm)
}
// StableMarshal encodes message 'm' using the invocation from related gRPC message
func StableMarshal[M protoutil.StableMarshaller](m Message, buf []byte) []byte {
return m.ToGRPCMessage().(M).StableMarshal(buf)
}
// StableSize encodes message 'm' using the invocation from related gRPC message
func StableSize[M protoutil.StableMarshaller](m Message) int {
return m.ToGRPCMessage().(M).StableSize()
}