#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum ImperialAramaic {
LetterAleph,
LetterBeth,
LetterGimel,
LetterDaleth,
LetterHe,
LetterWaw,
LetterZayin,
LetterHeth,
LetterTeth,
LetterYodh,
LetterKaph,
LetterLamedh,
LetterMem,
LetterNun,
LetterSamekh,
LetterAyin,
LetterPe,
LetterSadhe,
LetterQoph,
LetterResh,
LetterShin,
LetterTaw,
SectionSign,
NumberOne,
NumberTwo,
NumberThree,
NumberTen,
NumberTwenty,
NumberOneHundred,
NumberOneThousand,
}
impl Into<char> for ImperialAramaic {
fn into(self) -> char {
match self {
ImperialAramaic::LetterAleph => '𐡀',
ImperialAramaic::LetterBeth => '𐡁',
ImperialAramaic::LetterGimel => '𐡂',
ImperialAramaic::LetterDaleth => '𐡃',
ImperialAramaic::LetterHe => '𐡄',
ImperialAramaic::LetterWaw => '𐡅',
ImperialAramaic::LetterZayin => '𐡆',
ImperialAramaic::LetterHeth => '𐡇',
ImperialAramaic::LetterTeth => '𐡈',
ImperialAramaic::LetterYodh => '𐡉',
ImperialAramaic::LetterKaph => '𐡊',
ImperialAramaic::LetterLamedh => '𐡋',
ImperialAramaic::LetterMem => '𐡌',
ImperialAramaic::LetterNun => '𐡍',
ImperialAramaic::LetterSamekh => '𐡎',
ImperialAramaic::LetterAyin => '𐡏',
ImperialAramaic::LetterPe => '𐡐',
ImperialAramaic::LetterSadhe => '𐡑',
ImperialAramaic::LetterQoph => '𐡒',
ImperialAramaic::LetterResh => '𐡓',
ImperialAramaic::LetterShin => '𐡔',
ImperialAramaic::LetterTaw => '𐡕',
ImperialAramaic::SectionSign => '𐡗',
ImperialAramaic::NumberOne => '𐡘',
ImperialAramaic::NumberTwo => '𐡙',
ImperialAramaic::NumberThree => '𐡚',
ImperialAramaic::NumberTen => '𐡛',
ImperialAramaic::NumberTwenty => '𐡜',
ImperialAramaic::NumberOneHundred => '𐡝',
ImperialAramaic::NumberOneThousand => '𐡞',
}
}
}
impl std::convert::TryFrom<char> for ImperialAramaic {
type Error = ();
fn try_from(c: char) -> Result<Self, Self::Error> {
match c {
'𐡀' => Ok(ImperialAramaic::LetterAleph),
'𐡁' => Ok(ImperialAramaic::LetterBeth),
'𐡂' => Ok(ImperialAramaic::LetterGimel),
'𐡃' => Ok(ImperialAramaic::LetterDaleth),
'𐡄' => Ok(ImperialAramaic::LetterHe),
'𐡅' => Ok(ImperialAramaic::LetterWaw),
'𐡆' => Ok(ImperialAramaic::LetterZayin),
'𐡇' => Ok(ImperialAramaic::LetterHeth),
'𐡈' => Ok(ImperialAramaic::LetterTeth),
'𐡉' => Ok(ImperialAramaic::LetterYodh),
'𐡊' => Ok(ImperialAramaic::LetterKaph),
'𐡋' => Ok(ImperialAramaic::LetterLamedh),
'𐡌' => Ok(ImperialAramaic::LetterMem),
'𐡍' => Ok(ImperialAramaic::LetterNun),
'𐡎' => Ok(ImperialAramaic::LetterSamekh),
'𐡏' => Ok(ImperialAramaic::LetterAyin),
'𐡐' => Ok(ImperialAramaic::LetterPe),
'𐡑' => Ok(ImperialAramaic::LetterSadhe),
'𐡒' => Ok(ImperialAramaic::LetterQoph),
'𐡓' => Ok(ImperialAramaic::LetterResh),
'𐡔' => Ok(ImperialAramaic::LetterShin),
'𐡕' => Ok(ImperialAramaic::LetterTaw),
'𐡗' => Ok(ImperialAramaic::SectionSign),
'𐡘' => Ok(ImperialAramaic::NumberOne),
'𐡙' => Ok(ImperialAramaic::NumberTwo),
'𐡚' => Ok(ImperialAramaic::NumberThree),
'𐡛' => Ok(ImperialAramaic::NumberTen),
'𐡜' => Ok(ImperialAramaic::NumberTwenty),
'𐡝' => Ok(ImperialAramaic::NumberOneHundred),
'𐡞' => Ok(ImperialAramaic::NumberOneThousand),
_ => Err(()),
}
}
}
impl Into<u32> for ImperialAramaic {
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 ImperialAramaic {
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 ImperialAramaic {
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 ImperialAramaic {
pub fn new() -> Self {
ImperialAramaic::LetterAleph
}
pub fn name(&self) -> String {
let s = std::format!("ImperialAramaic{:#?}", self);
string_morph::to_sentence_case(&s)
}
}