use crate::prelude::*;
bitfield! {
#[lsb_first]
pub struct BitfieldStruct24: 24 {
pub bit: 1,
pub flag: 1 as bool,
pub multi_bit: 5,
pub custom_bitint: 3 as CustomBitint3,
pub custom_primitive: 8 as CustomPrimitive8,
..
}
#[lsb_first]
pub struct BitfieldStruct32: 32 {
pub bit: 1,
pub flag: 1 as bool,
pub multi_bit: 5,
pub custom_bitint: 3 as CustomBitint3,
pub custom_primitive: 8 as CustomPrimitive8,
..
}
}
pub struct CustomBitint3(pub U3);
impl From<U3> for CustomBitint3 {
fn from(value: U3) -> Self {
Self(value)
}
}
impl From<CustomBitint3> for U3 {
fn from(value: CustomBitint3) -> Self {
value.0
}
}
pub struct CustomPrimitive8(pub u8);
impl From<U8> for CustomPrimitive8 {
fn from(value: U8) -> Self {
Self(value.to_primitive())
}
}
impl From<CustomPrimitive8> for U8 {
fn from(value: CustomPrimitive8) -> Self {
U8::from_primitive(value.0)
}
}