You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to export EncodeBytesLen() in the encoder APIs? My use case is that I need to encode a large number of items, each of which contains an ID, which in turn contains a prefix, a body, and a suffix, all of which are byte slices, e.g.,
type ID struct {
Prefix []byte
Body []byte
Suffix []byte
}
What I'd like to achieve is to encode the ID object as if it were a single []byte so that I can avoid unnecessary byte copies during decoding. With the existing API, I'd have to concatenate the prefix/body/suffix and create a new byte slice to use the EncodeBytes method. However if we export EncodeBytesLen(), I can call EncodeBytesLen() to encode the number of bytes first, then write the raw bytes.
If that sounds reasonable, I'd be happy to put up a PR.
The text was updated successfully, but these errors were encountered:
Is it possible to export
EncodeBytesLen()
in the encoder APIs? My use case is that I need to encode a large number of items, each of which contains an ID, which in turn contains a prefix, a body, and a suffix, all of which are byte slices, e.g.,What I'd like to achieve is to encode the
ID
object as if it were a single[]byte
so that I can avoid unnecessary byte copies during decoding. With the existing API, I'd have to concatenate the prefix/body/suffix and create a new byte slice to use theEncodeBytes
method. However if we exportEncodeBytesLen()
, I can callEncodeBytesLen()
to encode the number of bytes first, then write the raw bytes.If that sounds reasonable, I'd be happy to put up a PR.
The text was updated successfully, but these errors were encountered: