hashmismatch / packed_struct.rs

Bit-level packing and unpacking for Rust
MIT License
164 stars 30 forks source link

[not_a_bug] indexing using bytes and bits #104

Closed manio closed 1 year ago

manio commented 1 year ago

Hi. Sorry for creating issue but I don't see the Discussions enabled for this project. I have a struct which is not fully populated with data - it is zero gaped and only single bytes have some meanings.

I want to ask if if is possible to do something like below:

    #[packed_field(byte = "0x08", bits="5")]
    power: bool,
    #[packed_field(byte = "0x00", bits="0..=5")]
    target_temp_int: Integer<u8, packed_bits::Bits::<6>>,
    #[packed_field(byte = "0x04", bits="0..=1")]
    target_temp_fract: Integer<u8, packed_bits::Bits::<2>>,

I mean to specify byte and then some bits from this byte. Currently it is telling me that field are overlapping. Am I correct that I need to use bits or bytes only for one field?

manio commented 1 year ago

Got the answer in https://github.com/hashmismatch/packed_struct.rs/issues/61 Closing