const FLAG_REQUIRED: u8 = 1 << 0;
const FLAG_DEFERRABLE: u8 = 1 << 1;
const FLAG_EARLY: u8 = 1 << 2;
const FLAG_FALLBACK: u8 = 1 << 3;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct RegistrationFlags(u8);
impl RegistrationFlags {
#[must_use]
pub const fn new() -> Self {
Self(0)
}
#[must_use]
pub const fn required() -> Self {
Self(FLAG_REQUIRED)
}
#[must_use]
pub const fn deferrable() -> Self {
Self(FLAG_DEFERRABLE)
}
#[must_use]
pub const fn set_required(mut self) -> Self {
self.0 |= FLAG_REQUIRED;
self
}
#[must_use]
pub const fn set_deferrable(mut self) -> Self {
self.0 |= FLAG_DEFERRABLE;
self
}
#[must_use]
pub const fn set_early(mut self) -> Self {
self.0 |= FLAG_EARLY;
self
}
#[must_use]
pub const fn set_fallback(mut self) -> Self {
self.0 |= FLAG_FALLBACK;
self
}
#[must_use]
pub const fn is_required(self) -> bool {
self.0 & FLAG_REQUIRED != 0
}
#[must_use]
pub const fn is_deferrable(self) -> bool {
self.0 & FLAG_DEFERRABLE != 0
}
#[must_use]
pub const fn is_early(self) -> bool {
self.0 & FLAG_EARLY != 0
}
#[must_use]
pub const fn is_fallback(self) -> bool {
self.0 & FLAG_FALLBACK != 0
}
}