[#49] util/proto: Make NestedStructure* generic

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-07-26 18:12:27 +03:00
parent 849de02bc3
commit 6e92d7d5de

View file

@ -255,7 +255,7 @@ func NestedStructurePrefix(field int64) (prefix uint64, ln int) {
return prefix, VarUIntSize(prefix)
}
func NestedStructureMarshal(field int64, buf []byte, v stableMarshaller) int {
func NestedStructureMarshal[T stableMarshaller](field int64, buf []byte, v T) int {
n := v.StableSize()
if n == 0 {
return 0
@ -269,7 +269,7 @@ func NestedStructureMarshal(field int64, buf []byte, v stableMarshaller) int {
return offset + n
}
func NestedStructureSize(field int64, v stableMarshaller) (size int) {
func NestedStructureSize[T stableMarshaller](field int64, v T) (size int) {
n := v.StableSize()
if n == 0 {
return 0