Bitbite derive
The Bitbite derive is used to save you a bit of code and make the usage cleaner.
For the cleanest code I recommend using deref_derive
Usage:
use bitbite::*;
use bitbite_derive::Bitbite;
use deref_derive::*;
#[derive(Bitbite, Deref, DerefMut)]
struct Header(pub u8);
impl Header {
pub const FIRST_NIBBLE_FLAG : Flag<u8> = Flag::new(0b0000_1111);
}
let h = Header(0b1100_1010);
assert_eq!(h.get_flag(&Header::FIRST_NIBBLE_FLAG), 0b1010);
Multi fielded structs
In case you have more than one field you can use the bitbite attribute
Usage:
use *;
use Bitbite;
use *;
let h = Header ;
assert_eq!;