mithril_common/era/
supported_era.rsuse serde::{Deserialize, Serialize};
use strum::{Display, EnumIter, EnumString, IntoEnumIterator};
#[derive(
Display, EnumString, EnumIter, Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize,
)]
#[serde(rename_all = "lowercase")]
#[strum(serialize_all = "lowercase")]
pub enum SupportedEra {
Thales,
Pythagoras,
}
impl SupportedEra {
pub fn eras() -> Vec<Self> {
Self::iter().collect()
}
pub fn dummy() -> Self {
Self::eras().first().unwrap().to_owned()
}
}
#[cfg(test)]
mod tests {
use super::*;
use std::str::FromStr;
#[test]
fn correct_number_of_eras() {
let total_eras = SupportedEra::eras().len();
assert!(total_eras > 0);
assert!(total_eras <= 2);
}
#[test]
fn from_str() {
let supported_era = SupportedEra::from_str(&SupportedEra::dummy().to_string())
.expect("This era name should be supported.");
assert_eq!(SupportedEra::dummy(), supported_era);
}
}