heapless icon indicating copy to clipboard operation
heapless copied to clipboard

Serialize Vec<u8> as bytes

Open nickray opened this issue 5 years ago • 0 comments

Some serialization formats distinguish between arrays of bytes and byte strings.

One approach is to defer to serde-bytes, https://github.com/serde-rs/bytes/pull/18.

An alternative is that heapless has a specialized Vec<u8> wrapper type, with its own ser/de routines, but delegating everything else to Vec. This is probably preferable, to have all the traits available.

Thoughts? I could give this a try if there is support to include such a Bytes type here (I have a private/non-polished POC that does the obvious thing). Maybe there are other properties it could have over a generic Vec, such as Ord or (maybe?) more efficient extend_from_slice, and more natural target of String::into_bytes.

nickray avatar Dec 30 '19 22:12 nickray