#[allow(missing_docs)] #[non_exhaustive]
#[derive(
::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::Ord, ::std::cmp::PartialEq, ::std::cmp::PartialOrd, ::std::fmt::Debug, ::std::hash::Hash,
)]
pub enum Locale {
#[allow(missing_docs)] DeDe,
#[allow(missing_docs)] EnAu,
#[allow(missing_docs)] EnGb,
#[allow(missing_docs)] EnIn,
#[allow(missing_docs)] EnUs,
#[allow(missing_docs)] Es419,
#[allow(missing_docs)] EsEs,
#[allow(missing_docs)] EsUs,
#[allow(missing_docs)] FrCa,
#[allow(missing_docs)] FrFr,
#[allow(missing_docs)] ItIt,
#[allow(missing_docs)] JaJp,
#[allow(missing_docs)] KoKr,
#[deprecated(note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants.")]
Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue),
}
impl ::std::convert::From<&str> for Locale {
fn from(s: &str) -> Self {
match s {
"de-DE" => Locale::DeDe,
"en-AU" => Locale::EnAu,
"en-GB" => Locale::EnGb,
"en-IN" => Locale::EnIn,
"en-US" => Locale::EnUs,
"es-419" => Locale::Es419,
"es-ES" => Locale::EsEs,
"es-US" => Locale::EsUs,
"fr-CA" => Locale::FrCa,
"fr-FR" => Locale::FrFr,
"it-IT" => Locale::ItIt,
"ja-JP" => Locale::JaJp,
"ko-KR" => Locale::KoKr,
other => Locale::Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue(other.to_owned())),
}
}
}
impl ::std::str::FromStr for Locale {
type Err = ::std::convert::Infallible;
fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
::std::result::Result::Ok(Locale::from(s))
}
}
impl Locale {
pub fn as_str(&self) -> &str {
match self {
Locale::DeDe => "de-DE",
Locale::EnAu => "en-AU",
Locale::EnGb => "en-GB",
Locale::EnIn => "en-IN",
Locale::EnUs => "en-US",
Locale::Es419 => "es-419",
Locale::EsEs => "es-ES",
Locale::EsUs => "es-US",
Locale::FrCa => "fr-CA",
Locale::FrFr => "fr-FR",
Locale::ItIt => "it-IT",
Locale::JaJp => "ja-JP",
Locale::KoKr => "ko-KR",
Locale::Unknown(value) => value.as_str(),
}
}
pub const fn values() -> &'static [&'static str] {
&[
"de-DE", "en-AU", "en-GB", "en-IN", "en-US", "es-419", "es-ES", "es-US", "fr-CA", "fr-FR", "it-IT", "ja-JP", "ko-KR",
]
}
}
impl ::std::convert::AsRef<str> for Locale {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl Locale {
pub fn try_parse(value: &str) -> ::std::result::Result<Self, crate::error::UnknownVariantError> {
match Self::from(value) {
#[allow(deprecated)]
Self::Unknown(_) => ::std::result::Result::Err(crate::error::UnknownVariantError::new(value)),
known => Ok(known),
}
}
}
impl ::std::fmt::Display for Locale {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
match self {
Locale::DeDe => write!(f, "de-DE"),
Locale::EnAu => write!(f, "en-AU"),
Locale::EnGb => write!(f, "en-GB"),
Locale::EnIn => write!(f, "en-IN"),
Locale::EnUs => write!(f, "en-US"),
Locale::Es419 => write!(f, "es-419"),
Locale::EsEs => write!(f, "es-ES"),
Locale::EsUs => write!(f, "es-US"),
Locale::FrCa => write!(f, "fr-CA"),
Locale::FrFr => write!(f, "fr-FR"),
Locale::ItIt => write!(f, "it-IT"),
Locale::JaJp => write!(f, "ja-JP"),
Locale::KoKr => write!(f, "ko-KR"),
Locale::Unknown(value) => write!(f, "{value}"),
}
}
}