Closed nickray closed 4 years ago
For embedded use cases, instead of alloc it's often preferable to use heapless: fixed-capacity strings and vectors. This patch would allow serializing Vec<u8> as byte strings instead of generic vectors.
alloc
heapless
Vec<u8>
A minimal example: https://github.com/nickray/serde-bytes-heapless-test/blob/master/src/lib.rs
I think it would be nice to have this patch here, would that make sense? The alternative being heapless having a Bytes type itself (https://github.com/japaric/heapless/issues/138).
Bytes
Regarding tests, I'm not sure how they could be added.
Regarding error handling, I'm not sure if or how to map capacity errors when deserializing instead of horribly panicking.
Understood. I am currently maintaining https://crates.io/crates/heapless-bytes and working towards merging this into heapless proper (https://github.com/japaric/heapless/pull/164).
For embedded use cases, instead of
alloc
it's often preferable to useheapless
: fixed-capacity strings and vectors. This patch would allow serializingVec<u8>
as byte strings instead of generic vectors.A minimal example: https://github.com/nickray/serde-bytes-heapless-test/blob/master/src/lib.rs
I think it would be nice to have this patch here, would that make sense? The alternative being
heapless
having aBytes
type itself (https://github.com/japaric/heapless/issues/138).Regarding tests, I'm not sure how they could be added.
Regarding error handling, I'm not sure if or how to map capacity errors when deserializing instead of horribly panicking.