bitflags!() { /* proc-macro */ }
Expand description
Generates a bitflags structure that can be formatted with defmt.
This macro is a wrapper around the bitflags!
crate, and provides an (almost) identical
interface. Refer to its documentation for an explanation of the syntax.
§Limitations
This macro only supports bitflags structs represented as one of Rust’s built-in unsigned integer
types (u8
, u16
, u32
, u64
, or u128
). Custom types are not supported. This restriction
is necessary to support defmt’s efficient encoding.
§Examples
The example from the bitflags crate works as-is:
defmt::bitflags! {
struct Flags: u32 {
const A = 0b00000001;
const B = 0b00000010;
const C = 0b00000100;
const ABC = Self::A.bits | Self::B.bits | Self::C.bits;
}
}
defmt::info!("Flags::ABC: {}", Flags::ABC);
defmt::info!("Flags::empty(): {}", Flags::empty());