bitx 0.1.0

More ergonomic way to deal with bitfield-like struct.
Documentation

bitx Version License Docs

bitx provides a prodecural macro for defining structures with precise bit-level and byte-level fields, using more ergonomic syntax.

At a glance

use bitx::bits;

bits! {
    #[derive(Clone, Copy)]
    pub struct Header: 4.4 { // size in `byte.bit` notation (so 36-bit)
        // 1-bit fields automatically return `bool`
        0.0 pub is_active: u1,

        // Custom bit-widths are supported
        0.1 pub status: u3,
        
        // The `.0` bit offset can be omitted.
        1 pub payload: u16,

        // Unaligned cross-byte field
        3.4 checksum: u8,
    }
}

See docs.rs for more information.

License

This project is licensed under either of

at your option.