use core::fmt::{self, Display, LowerHex, UpperHex};
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Ord, PartialOrd)]
#[repr(u32)]
pub enum Space {
Generic = 0x0000,
Wifi = 0x0B00,
Mask = 0xFF00,
}
impl Space {
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Generic => "SL_STATUS_GENERIC_SPACE",
Self::Wifi => "SL_STATUS_WIFI_SPACE",
Self::Mask => "SL_STATUS_SPACE_MASK",
}
}
}
impl Display for Space {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl LowerHex for Space {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:#010x}", *self as u32)
}
}
impl UpperHex for Space {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:#010X}", *self as u32)
}
}