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

Use the zerocopy library for marshalling/unmarshalling #11

Closed
kupiakos opened this issue Aug 25, 2023 · 1 comment
Closed

Use the zerocopy library for marshalling/unmarshalling #11

kupiakos opened this issue Aug 25, 2023 · 1 comment

Comments

@kupiakos
Copy link
Contributor

kupiakos commented Aug 25, 2023

zerocopy is a Rust library designed to enable simple and safe zero-copy serialization and deserialization, aka no-cost marshaling/unmarshaling.

It does this through a set of marker traits:

  • AsBytes marks a type as safe to convert to bytes, which means it has no padding or possibly-uninit bytes.
  • FromBytes marks a type as valid for every possible initialized bit pattern. Integers, arrays, and #[repr(C)] structs of FromBytes types qualify. The only place this could cause issues is with is with proper enum types, and open-enum aims to help with that.

It also provides derive(FromBytes) and derive(AsBytes), which check that your struct fits the safety conditions and has a stable layout. Through these traits and macros, it defines safe conversions that are mostly out of the way.

I'm working with upstream to improve the library greatly. In particular, the TryFromBytes feature will allow us to define fallible conversions for types that aren't FromBytes and automatically use a verifier function when converting to/from bytes.

@kupiakos kupiakos assigned esmusick and unassigned esmusick Sep 2, 2023
@esmusick
Copy link
Contributor

esmusick commented Oct 6, 2023

zerocopy is now used underlying all marshaling/unmarshaling with #17 and #24

@esmusick esmusick closed this as completed Oct 6, 2023
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

2 participants