modular-bitfield 0.11.2

Allows to easily define bitfield types with modular building blocks.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use modular_bitfield::prelude::*;

// Is only 9 bits, so will be 2 bytes in size.
#[bitfield(bytes = 2, filled = false)]
#[derive(BitfieldSpecifier)]
pub struct Header {
    a: B6,
    b: bool,
    c: bool,
    d: bool,
}

fn main() {
    assert_eq!(core::mem::size_of::<Header>(), 2)
}