#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum Avestan {
LetterA,
LetterAa,
LetterAo,
LetterAao,
LetterAn,
LetterAan,
LetterAe,
LetterAee,
LetterE,
LetterEe,
LetterO,
LetterOo,
LetterI,
LetterIi,
LetterU,
LetterUu,
LetterKe,
LetterXe,
LetterXye,
LetterXve,
LetterGe,
LetterGge,
LetterGhe,
LetterCe,
LetterJe,
LetterTe,
LetterThe,
LetterDe,
LetterDhe,
LetterTte,
LetterPe,
LetterFe,
LetterBe,
LetterBhe,
LetterNge,
LetterNgye,
LetterNgve,
LetterNe,
LetterNye,
LetterNne,
LetterMe,
LetterHme,
LetterYye,
LetterYe,
LetterVe,
LetterRe,
LetterLe,
LetterSe,
LetterZe,
LetterShe,
LetterZhe,
LetterShye,
LetterSshe,
LetterHe,
AbbreviationMark,
TinyTwoDotsOverOneDotPunctuation,
SmallTwoDotsOverOneDotPunctuation,
LargeTwoDotsOverOneDotPunctuation,
LargeOneDotOverTwoDotsPunctuation,
LargeTwoRingsOverOneRingPunctuation,
}
impl Into<char> for Avestan {
fn into(self) -> char {
match self {
Avestan::LetterA => '𐬀',
Avestan::LetterAa => '𐬁',
Avestan::LetterAo => '𐬂',
Avestan::LetterAao => '𐬃',
Avestan::LetterAn => '𐬄',
Avestan::LetterAan => '𐬅',
Avestan::LetterAe => '𐬆',
Avestan::LetterAee => '𐬇',
Avestan::LetterE => '𐬈',
Avestan::LetterEe => '𐬉',
Avestan::LetterO => '𐬊',
Avestan::LetterOo => '𐬋',
Avestan::LetterI => '𐬌',
Avestan::LetterIi => '𐬍',
Avestan::LetterU => '𐬎',
Avestan::LetterUu => '𐬏',
Avestan::LetterKe => '𐬐',
Avestan::LetterXe => '𐬑',
Avestan::LetterXye => '𐬒',
Avestan::LetterXve => '𐬓',
Avestan::LetterGe => '𐬔',
Avestan::LetterGge => '𐬕',
Avestan::LetterGhe => '𐬖',
Avestan::LetterCe => '𐬗',
Avestan::LetterJe => '𐬘',
Avestan::LetterTe => '𐬙',
Avestan::LetterThe => '𐬚',
Avestan::LetterDe => '𐬛',
Avestan::LetterDhe => '𐬜',
Avestan::LetterTte => '𐬝',
Avestan::LetterPe => '𐬞',
Avestan::LetterFe => '𐬟',
Avestan::LetterBe => '𐬠',
Avestan::LetterBhe => '𐬡',
Avestan::LetterNge => '𐬢',
Avestan::LetterNgye => '𐬣',
Avestan::LetterNgve => '𐬤',
Avestan::LetterNe => '𐬥',
Avestan::LetterNye => '𐬦',
Avestan::LetterNne => '𐬧',
Avestan::LetterMe => '𐬨',
Avestan::LetterHme => '𐬩',
Avestan::LetterYye => '𐬪',
Avestan::LetterYe => '𐬫',
Avestan::LetterVe => '𐬬',
Avestan::LetterRe => '𐬭',
Avestan::LetterLe => '𐬮',
Avestan::LetterSe => '𐬯',
Avestan::LetterZe => '𐬰',
Avestan::LetterShe => '𐬱',
Avestan::LetterZhe => '𐬲',
Avestan::LetterShye => '𐬳',
Avestan::LetterSshe => '𐬴',
Avestan::LetterHe => '𐬵',
Avestan::AbbreviationMark => '𐬹',
Avestan::TinyTwoDotsOverOneDotPunctuation => '𐬺',
Avestan::SmallTwoDotsOverOneDotPunctuation => '𐬻',
Avestan::LargeTwoDotsOverOneDotPunctuation => '𐬼',
Avestan::LargeOneDotOverTwoDotsPunctuation => '𐬽',
Avestan::LargeTwoRingsOverOneRingPunctuation => '𐬾',
}
}
}
impl std::convert::TryFrom<char> for Avestan {
type Error = ();
fn try_from(c: char) -> Result<Self, Self::Error> {
match c {
'𐬀' => Ok(Avestan::LetterA),
'𐬁' => Ok(Avestan::LetterAa),
'𐬂' => Ok(Avestan::LetterAo),
'𐬃' => Ok(Avestan::LetterAao),
'𐬄' => Ok(Avestan::LetterAn),
'𐬅' => Ok(Avestan::LetterAan),
'𐬆' => Ok(Avestan::LetterAe),
'𐬇' => Ok(Avestan::LetterAee),
'𐬈' => Ok(Avestan::LetterE),
'𐬉' => Ok(Avestan::LetterEe),
'𐬊' => Ok(Avestan::LetterO),
'𐬋' => Ok(Avestan::LetterOo),
'𐬌' => Ok(Avestan::LetterI),
'𐬍' => Ok(Avestan::LetterIi),
'𐬎' => Ok(Avestan::LetterU),
'𐬏' => Ok(Avestan::LetterUu),
'𐬐' => Ok(Avestan::LetterKe),
'𐬑' => Ok(Avestan::LetterXe),
'𐬒' => Ok(Avestan::LetterXye),
'𐬓' => Ok(Avestan::LetterXve),
'𐬔' => Ok(Avestan::LetterGe),
'𐬕' => Ok(Avestan::LetterGge),
'𐬖' => Ok(Avestan::LetterGhe),
'𐬗' => Ok(Avestan::LetterCe),
'𐬘' => Ok(Avestan::LetterJe),
'𐬙' => Ok(Avestan::LetterTe),
'𐬚' => Ok(Avestan::LetterThe),
'𐬛' => Ok(Avestan::LetterDe),
'𐬜' => Ok(Avestan::LetterDhe),
'𐬝' => Ok(Avestan::LetterTte),
'𐬞' => Ok(Avestan::LetterPe),
'𐬟' => Ok(Avestan::LetterFe),
'𐬠' => Ok(Avestan::LetterBe),
'𐬡' => Ok(Avestan::LetterBhe),
'𐬢' => Ok(Avestan::LetterNge),
'𐬣' => Ok(Avestan::LetterNgye),
'𐬤' => Ok(Avestan::LetterNgve),
'𐬥' => Ok(Avestan::LetterNe),
'𐬦' => Ok(Avestan::LetterNye),
'𐬧' => Ok(Avestan::LetterNne),
'𐬨' => Ok(Avestan::LetterMe),
'𐬩' => Ok(Avestan::LetterHme),
'𐬪' => Ok(Avestan::LetterYye),
'𐬫' => Ok(Avestan::LetterYe),
'𐬬' => Ok(Avestan::LetterVe),
'𐬭' => Ok(Avestan::LetterRe),
'𐬮' => Ok(Avestan::LetterLe),
'𐬯' => Ok(Avestan::LetterSe),
'𐬰' => Ok(Avestan::LetterZe),
'𐬱' => Ok(Avestan::LetterShe),
'𐬲' => Ok(Avestan::LetterZhe),
'𐬳' => Ok(Avestan::LetterShye),
'𐬴' => Ok(Avestan::LetterSshe),
'𐬵' => Ok(Avestan::LetterHe),
'𐬹' => Ok(Avestan::AbbreviationMark),
'𐬺' => Ok(Avestan::TinyTwoDotsOverOneDotPunctuation),
'𐬻' => Ok(Avestan::SmallTwoDotsOverOneDotPunctuation),
'𐬼' => Ok(Avestan::LargeTwoDotsOverOneDotPunctuation),
'𐬽' => Ok(Avestan::LargeOneDotOverTwoDotsPunctuation),
'𐬾' => Ok(Avestan::LargeTwoRingsOverOneRingPunctuation),
_ => Err(()),
}
}
}
impl Into<u32> for Avestan {
fn into(self) -> u32 {
let c: char = self.into();
let hex = c
.escape_unicode()
.to_string()
.replace("\\u{", "")
.replace("}", "");
u32::from_str_radix(&hex, 16).unwrap()
}
}
impl std::convert::TryFrom<u32> for Avestan {
type Error = ();
fn try_from(u: u32) -> Result<Self, Self::Error> {
if let Ok(c) = char::try_from(u) {
Self::try_from(c)
} else {
Err(())
}
}
}
impl Iterator for Avestan {
type Item = Self;
fn next(&mut self) -> Option<Self> {
let index: u32 = (*self).into();
use std::convert::TryFrom;
Self::try_from(index + 1).ok()
}
}
impl Avestan {
pub fn new() -> Self {
Avestan::LetterA
}
pub fn name(&self) -> String {
let s = std::format!("Avestan{:#?}", self);
string_morph::to_sentence_case(&s)
}
}