bitcode icon indicating copy to clipboard operation
bitcode copied to clipboard

Implement Encode/Decode for &'a [u8]

Open DrSloth opened this issue 1 year ago • 4 comments

This would allow bitcode to serialize/deserialize arbitrary bytes (like non utf-8 strings) to be serialized/deserialized without the serde feature

DrSloth avatar Mar 25 '24 09:03 DrSloth

It's a bit tricky since u8s may be packed as u1 u2 u4 which can't be borrowed as u8 from input. It would require borrowing from a bitcode::Buffer after the u8s are unpacked.

caibear avatar Mar 25 '24 19:03 caibear

Good point, would it be possible to provide some wrapper type that gets serialized as raw bytes? My specific use case actually is that of non UTF-8 text. I kind of need str encoding but not UTF-8.

In my case i could also implement the traits by hand but that doesn't seem to be documented.

DrSloth avatar Mar 26 '24 08:03 DrSloth

And your use-case requires zero-copy for some reason? Otherwise you can use Vec<u8> or Box<[u8]>.

finnbear avatar Mar 26 '24 15:03 finnbear

Hi guys,

Thank you for great framework! Would be nice to see that feature!

Thank you!

myrgy avatar Aug 14 '24 13:08 myrgy