Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Encode/Decode for &'a [u8] #23

Open
DrSloth opened this issue Mar 25, 2024 · 4 comments
Open

Implement Encode/Decode for &'a [u8] #23

DrSloth opened this issue Mar 25, 2024 · 4 comments

Comments

@DrSloth
Copy link

DrSloth commented Mar 25, 2024

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

@DrSloth DrSloth changed the title Implement Encode/Decode for &'a ] Implement Encode/Decode for &'a [u8] Mar 25, 2024
@caibear
Copy link
Member

caibear commented Mar 25, 2024

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.

@DrSloth
Copy link
Author

DrSloth commented Mar 26, 2024

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.

@finnbear
Copy link
Member

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

@myrgy
Copy link

myrgy commented Aug 14, 2024

Hi guys,

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

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants