Crate u8bits

source ·
Expand description

A macro to generate bit field like getters and setters on structs which represent an array of bytes.

See the documentation of the macro for how to use it.

Re-exports

pub use paste;

Macros

This macro allows the generaion of bit field like getters and setters for a New Type struct of type [u8;N]. There are bit wise accessors and bit range accessors. The bitwise operations map to an boolean value whereas the bit range operations use an provided type which has to implement the .into() conversion trait. The bit wise field declaration is as follows:

Functions

Get the bit at position ‘pos’ of byte ‘b’.
Return the ‘value’ of byte ‘b’ in the range of the given bit positions ‘lsb’ (least significant bit) and ‘msb’ (most significant bit) inclusive.
Set the bit at position ‘pos’ of byte ‘b’.
Set the given ‘value’ in byte ‘b’ in the range of the given bit positions ‘lsb’ (least significant bit) and ‘msb’ (most significant bit) inclusive. the other bits are not touched.