packed_struct.rs
packed_struct.rs copied to clipboard
Bit-level packing and unpacking for Rust
Currently there is support for reserved bits sets to zero or one. ``` #[packed_field(bits="0..=2")] _zeroes: ReservedZero, #[packed_field(bits="3..=4")] _reserved_one: ReservedOne, ``` However there is no (it seems) way to define a...
Hey! First off, I love this library, takes a lot of the legwork out of writing device drivers. I noticed that the debug printing interface is not no_std. It would...
Rely on the compiler to optimize the primitive value lookups - the code gen won't resolve the values of the discriminants anymore. Enabled usage of any sort of possible enum...
I'd like to use `packed_struct` in a use case where the rust struct contains an enum, and the enum values are defined by constants generated by `bindgen`. Modifying the example...
Hi, I am trying to replace `modular_bitfield` with `packet_struct` as that library is no longer maintained. As such, I am trying to use `packet_struct` with a non-struct type as a...
I want to use packed_struct to implement [this protocol](https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/blob/832a331437d7b8d0bf9844f770d540929e6f2f97/Multiprotocol/Multiprotocol.h#L744). Unfortunately it uses split integers. By that I mean an integer which is derived by concatenating multiple bit sequences together. For...
I've got a somewhat odd, completely custom, CANBUS message format that I'm trying to serialize. It uses fixed point numbers which I'm storing as f32. Is it possible to use...
Currently, the bits types contain an associated byte type, which resolve to the exact size of the required byte array. This mapping between particular bit widths and bytes is done...
This code ```rust #[derive(PackedStruct)] #[packed_struct(bit_numbering="msb0")] pub struct PsMpf { #[packed_field(bytes="0", bits="2")] _reserved_h_2: ReservedOne, #[packed_field(bytes="0", bits="3")] _reserved_h_3: ReservedZero, #[packed_field(bytes="0", bits="4")] _reserved_h_4: ReservedOne, #[packed_field(bytes="0", bits="5")] _reserved_h_5: ReservedZero, #[packed_field(bytes="0", bits="6")] _reserved_h_6: ReservedOne, #[packed_field(bytes="0",...