use super::*; #[derive(Debug, PartialEq, PartialOrd, Copy, Clone)] pub enum Rarity { Common, Uncommon, Rare, Epic, Legendary, Mythic, } impl From for u8 { fn from(rarity: Rarity) -> Self { rarity as u8 } } impl TryFrom for Rarity { type Error = u8; fn try_from(rarity: u8) -> Result { match rarity { 0 => Ok(Self::Common), 1 => Ok(Self::Uncommon), 2 => Ok(Self::Rare), 3 => Ok(Self::Epic), 4 => Ok(Self::Legendary), 5 => Ok(Self::Mythic), n => Err(n), } } } impl Display for Rarity { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { write!( f, "{}", match self { Self::Common => "common", Self::Uncommon => "uncommon", Self::Rare => "rare", Self::Epic => "epic", Self::Legendary => "legendary", Self::Mythic => "mythic", } ) } } impl From for Rarity { fn from(sat: Sat) -> Self { let Degree { hour, minute, second,