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
use modular_bitfield::prelude::*;

#[bitfield(bits = 4)]
#[derive(BitfieldSpecifier)]
pub struct Header {
    is_compact: bool,
    is_secure: bool,
    #[bits = 2]
    pre_status: B2,
}

fn main() {
    assert_eq!(<Header as Specifier>::BITS, 4);
}