You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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 ofFromBytes
types qualify. The only place this could cause issues is with is with properenum
types, and open-enum aims to help with that.It also provides
derive(FromBytes)
andderive(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'tFromBytes
and automatically use a verifier function when converting to/from bytes.The text was updated successfully, but these errors were encountered: