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 {
self.as_str().fmt(f)
}
}
impl LowerHex for Space {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
LowerHex::fmt(&(*self as u32), f)
}
}
impl UpperHex for Space {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
UpperHex::fmt(&(*self as u32), f)
}
}