#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub enum ConfigTier {
System = 1,
Local = 2,
#[default]
User = 3,
}
impl From<ConfigTier> for u8 {
fn from(tier: ConfigTier) -> Self {
tier as Self
}
}
impl ConfigTier {
#[must_use]
pub const fn is_user(self) -> bool {
matches!(self, Self::User)
}
#[must_use]
pub const fn is_local(self) -> bool {
matches!(self, Self::Local)
}
#[must_use]
pub const fn is_system(self) -> bool {
matches!(self, Self::System)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_tier_ordering() {
assert!(ConfigTier::User > ConfigTier::Local);
assert!(ConfigTier::Local > ConfigTier::System);
assert!(ConfigTier::User > ConfigTier::System);
}
#[test]
fn test_priority_values() {
assert_eq!(u8::from(ConfigTier::User), 3);
assert_eq!(u8::from(ConfigTier::Local), 2);
assert_eq!(u8::from(ConfigTier::System), 1);
}
}