#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum InscriptionalParthian {
LetterAleph,
LetterBeth,
LetterGimel,
LetterDaleth,
LetterHe,
LetterWaw,
LetterZayin,
LetterHeth,
LetterTeth,
LetterYodh,
LetterKaph,
LetterLamedh,
LetterMem,
LetterNun,
LetterSamekh,
LetterAyin,
LetterPe,
LetterSadhe,
LetterQoph,
LetterResh,
LetterShin,
LetterTaw,
NumberOne,
NumberTwo,
NumberThree,
NumberFour,
NumberTen,
NumberTwenty,
NumberOneHundred,
}
impl Into<char> for InscriptionalParthian {
fn into(self) -> char {
match self {
InscriptionalParthian::LetterAleph => '𐭀',
InscriptionalParthian::LetterBeth => '𐭁',
InscriptionalParthian::LetterGimel => '𐭂',
InscriptionalParthian::LetterDaleth => '𐭃',
InscriptionalParthian::LetterHe => '𐭄',
InscriptionalParthian::LetterWaw => '𐭅',
InscriptionalParthian::LetterZayin => '𐭆',
InscriptionalParthian::LetterHeth => '𐭇',
InscriptionalParthian::LetterTeth => '𐭈',
InscriptionalParthian::LetterYodh => '𐭉',
InscriptionalParthian::LetterKaph => '𐭊',
InscriptionalParthian::LetterLamedh => '𐭋',
InscriptionalParthian::LetterMem => '𐭌',
InscriptionalParthian::LetterNun => '𐭍',
InscriptionalParthian::LetterSamekh => '𐭎',
InscriptionalParthian::LetterAyin => '𐭏',
InscriptionalParthian::LetterPe => '𐭐',
InscriptionalParthian::LetterSadhe => '𐭑',
InscriptionalParthian::LetterQoph => '𐭒',
InscriptionalParthian::LetterResh => '𐭓',
InscriptionalParthian::LetterShin => '𐭔',
InscriptionalParthian::LetterTaw => '𐭕',
InscriptionalParthian::NumberOne => '𐭘',
InscriptionalParthian::NumberTwo => '𐭙',
InscriptionalParthian::NumberThree => '𐭚',
InscriptionalParthian::NumberFour => '𐭛',
InscriptionalParthian::NumberTen => '𐭜',
InscriptionalParthian::NumberTwenty => '𐭝',
InscriptionalParthian::NumberOneHundred => '𐭞',
}
}
}
impl std::convert::TryFrom<char> for InscriptionalParthian {
type Error = ();
fn try_from(c: char) -> Result<Self, Self::Error> {
match c {
'𐭀' => Ok(InscriptionalParthian::LetterAleph),
'𐭁' => Ok(InscriptionalParthian::LetterBeth),
'𐭂' => Ok(InscriptionalParthian::LetterGimel),
'𐭃' => Ok(InscriptionalParthian::LetterDaleth),
'𐭄' => Ok(InscriptionalParthian::LetterHe),
'𐭅' => Ok(InscriptionalParthian::LetterWaw),
'𐭆' => Ok(InscriptionalParthian::LetterZayin),
'𐭇' => Ok(InscriptionalParthian::LetterHeth),
'𐭈' => Ok(InscriptionalParthian::LetterTeth),
'𐭉' => Ok(InscriptionalParthian::LetterYodh),
'𐭊' => Ok(InscriptionalParthian::LetterKaph),
'𐭋' => Ok(InscriptionalParthian::LetterLamedh),
'𐭌' => Ok(InscriptionalParthian::LetterMem),
'𐭍' => Ok(InscriptionalParthian::LetterNun),
'𐭎' => Ok(InscriptionalParthian::LetterSamekh),
'𐭏' => Ok(InscriptionalParthian::LetterAyin),
'𐭐' => Ok(InscriptionalParthian::LetterPe),
'𐭑' => Ok(InscriptionalParthian::LetterSadhe),
'𐭒' => Ok(InscriptionalParthian::LetterQoph),
'𐭓' => Ok(InscriptionalParthian::LetterResh),
'𐭔' => Ok(InscriptionalParthian::LetterShin),
'𐭕' => Ok(InscriptionalParthian::LetterTaw),
'𐭘' => Ok(InscriptionalParthian::NumberOne),
'𐭙' => Ok(InscriptionalParthian::NumberTwo),
'𐭚' => Ok(InscriptionalParthian::NumberThree),
'𐭛' => Ok(InscriptionalParthian::NumberFour),
'𐭜' => Ok(InscriptionalParthian::NumberTen),
'𐭝' => Ok(InscriptionalParthian::NumberTwenty),
'𐭞' => Ok(InscriptionalParthian::NumberOneHundred),
_ => Err(()),
}
}
}
impl Into<u32> for InscriptionalParthian {
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 InscriptionalParthian {
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 InscriptionalParthian {
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 InscriptionalParthian {
pub fn new() -> Self {
InscriptionalParthian::LetterAleph
}
pub fn name(&self) -> String {
let s = std::format!("InscriptionalParthian{:#?}", self);
string_morph::to_sentence_case(&s)
}
}