Derive Macro Flags
#[derive(Flags)]Expand description
Derives the operations and conversions of a bit flag struct.
The struct has one unnamed integer field that holds the bits. Its type
sets the D-Bus type. The struct must be Copy. Define the flags as
associated constants. Unknown bits are kept.
The derive adds empty, from_bits, bits, is_empty, contains,
intersects, union, intersection and difference, the |, & and
- operators, From the integer and back, zvariant Type, serde
Serialize and Deserialize, TryFrom<OwnedValue> and From<Self> for
Value.
#[derive(Clone, Copy, Debug, PartialEq, remora_derive::Flags)]
struct Access(u32);
impl Access {
const READ: Self = Self(1);
const WRITE: Self = Self(2);
}
let access = Access::READ | Access::WRITE;
assert!(access.contains(Access::WRITE));
assert_eq!((access - Access::READ).bits(), 2);