#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub enum ConfigTier {
#[default]
User = 3,
Local = 2,
System = 1,
}
impl ConfigTier {
#[must_use]
pub const fn priority(self) -> u8 {
match self {
Self::User => 3,
Self::Local => 2,
Self::System => 1,
}
}
#[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!(ConfigTier::User.priority(), 3);
assert_eq!(ConfigTier::Local.priority(), 2);
assert_eq!(ConfigTier::System.priority(), 1);
}
}