[][src]Macro sbp::parsable_bitflags

macro_rules! parsable_bitflags {
    {
        __impl impl, $name:ident, $target:ty, $endianness:ident
    } => { ... };
    {
        pub struct $name:ident: Le<$repr:ty> {
            $($body:tt)+
        }
    } => { ... };
    {
        struct $name:ident: Be<$repr:ty> {
            $($body:tt)+
        }
    } => { ... };
    {
        pub struct $name:ident: Le<$repr:ty> {
            $($body:tt)+
        }
    } => { ... };
    {
        struct $name:ident: Be<$repr:ty> {
            $($body:tt)+
        }
    } => { ... };
}

Declare a bitflags struct that can be parsed and serialized.

Only available if the bitflags feature has been enabled.

Example


parsable_bitflags! {
    pub struct MyStruct: Le<u16> {
        const FLAG_A = 0x8;
        const FLAG_B = 0x10;
        const FLAG_C = 0x200;
    }
}

let bytes = [0x18, 0x02];
let (my_struct, _length) = MyStruct::parse((), &bytes)?;
assert_eq!(my_struct, MyStruct::FLAG_A | MyStruct::FLAG_B | MyStruct::FLAG_C);