The bytes crate is extremely popular for handling I/O and parsing buffers in the crates ecosystem, especially in respect to crates that build on Tokio.
It ends up being rather annoying/inefficient to use a bytes::Bytes instance with der types, as it either involves creating a wrapper struct, e.g.:
or copying to/from an OctetString. This also invites potential mistakes because the most natural type to convert to is Vec<u8>, which der supports but which actually represents a SEQUENCE OF INTEGER, not an OCTET STRING.
In contrast, Bytes is pretty much as unambiguous as OctetString itself, with the caveat that it doesn't uphold the max-length guarantee that OctetString does.
This is an integration I'd be happy to contribute, because it would let me delete a good handful of lines of code on my end.
The
bytes
crate is extremely popular for handling I/O and parsing buffers in the crates ecosystem, especially in respect to crates that build on Tokio.It ends up being rather annoying/inefficient to use a
bytes::Bytes
instance withder
types, as it either involves creating a wrapper struct, e.g.:or copying to/from an
OctetString
. This also invites potential mistakes because the most natural type to convert to isVec<u8>
, whichder
supports but which actually represents aSEQUENCE OF INTEGER
, not anOCTET STRING
.In contrast,
Bytes
is pretty much as unambiguous asOctetString
itself, with the caveat that it doesn't uphold the max-length guarantee thatOctetString
does.This is an integration I'd be happy to contribute, because it would let me delete a good handful of lines of code on my end.