use std::fmt::Display;
use std::str::FromStr;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub enum EsportsLocales {
DE,
GB,
US,
FR,
TR,
PL,
}
impl Display for EsportsLocales {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
EsportsLocales::DE => write!(f, "de-DE"),
EsportsLocales::GB => write!(f, "en-GB"),
EsportsLocales::US => write!(f, "en-US"),
EsportsLocales::FR => write!(f, "fr-FR"),
EsportsLocales::TR => write!(f, "tr-TR"),
EsportsLocales::PL => write!(f, "pl-PL"),
}
}
}
impl FromStr for EsportsLocales {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"de-DE" => Ok(EsportsLocales::DE),
"en-GB" => Ok(EsportsLocales::GB),
"en-US" => Ok(EsportsLocales::US),
"fr-FR" => Ok(EsportsLocales::FR),
"tr-TR" => Ok(EsportsLocales::TR),
"pl-PL" => Ok(EsportsLocales::PL),
_ => Err(format!("{s} is not a valid locale")),
}
}
}