Implement bincode Writer and Reader traits for Vec
I am working on a no_std embedded comms stack which talks to devices running C applications. The stack uses heapless::Vecs to handle the byte streams being sent and received, and I would like to use bincode to perform the conversion to / from Rust structures.
Right now, in order to do this I have to create a wrapper type around the heapless::Vec in order to implement bincode's Writer and Reader traits. It seems like this is a common enough pairing that it would make sense to have these traits implemented for heapless::Vec by default, or at least available through a feature, rather than having to re-implement for each new project working in this space.
I'm not sure whether it would make more sense for this implementation to live in the bincode crate or the heapless crate, so I've created an equivalent issue on the bincode repo. What do you think?
Might be relevant:
- Postcard provides its own implementations there: https://docs.rs/postcard/latest/postcard/fn.to_vec.html
- cbor_smol also does the same
- https://github.com/rust-embedded/heapless/pull/340 might be interesting to get similar functionality without needing dedicated implementations.
Yeah agreed, to me it would seem like it would make more sense for the implementation to live in the serialiser's crate rather than the collection's crate. Good to know there's precedent.
Hi! Looks like the bincode maintainers have taken the opposite perspective.
Thoughts on how we can resolve?
Well if the bin code maintainers are not interested in adding heapless support I guess it's up to the heapless maintainers whether they want to add bincode support...that does seem the wrong way round to me though.
It seems we are at an impasse. I can write a third party integration crate if we have to, but would prefer to resolve this through diplomacy! (C+P from there)