#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum Sogdian {
LetterAleph,
LetterBeth,
LetterGimel,
LetterHe,
LetterWaw,
LetterZayin,
LetterHeth,
LetterYodh,
LetterKaph,
LetterLamedh,
LetterMem,
LetterNun,
LetterSamekh,
LetterAyin,
LetterPe,
LetterSadhe,
LetterReshDashAyin,
LetterShin,
LetterTaw,
LetterFeth,
LetterLesh,
IndependentShin,
CombiningDotBelow,
CombiningTwoDotsBelow,
CombiningDotAbove,
CombiningTwoDotsAbove,
CombiningCurveAbove,
CombiningCurveBelow,
CombiningHookAbove,
CombiningHookBelow,
CombiningLongHookBelow,
CombiningReshBelow,
CombiningStrokeBelow,
NumberOne,
NumberTen,
NumberTwenty,
NumberOneHundred,
PunctuationTwoVerticalBars,
PunctuationTwoVerticalBarsWithDots,
PunctuationCircleWithDot,
PunctuationTwoCirclesWithDots,
PunctuationHalfCircleWithDot,
}
impl Into<char> for Sogdian {
fn into(self) -> char {
match self {
Sogdian::LetterAleph => '𐼰',
Sogdian::LetterBeth => '𐼱',
Sogdian::LetterGimel => '𐼲',
Sogdian::LetterHe => '𐼳',
Sogdian::LetterWaw => '𐼴',
Sogdian::LetterZayin => '𐼵',
Sogdian::LetterHeth => '𐼶',
Sogdian::LetterYodh => '𐼷',
Sogdian::LetterKaph => '𐼸',
Sogdian::LetterLamedh => '𐼹',
Sogdian::LetterMem => '𐼺',
Sogdian::LetterNun => '𐼻',
Sogdian::LetterSamekh => '𐼼',
Sogdian::LetterAyin => '𐼽',
Sogdian::LetterPe => '𐼾',
Sogdian::LetterSadhe => '𐼿',
Sogdian::LetterReshDashAyin => '𐽀',
Sogdian::LetterShin => '𐽁',
Sogdian::LetterTaw => '𐽂',
Sogdian::LetterFeth => '𐽃',
Sogdian::LetterLesh => '𐽄',
Sogdian::IndependentShin => '𐽅',
Sogdian::CombiningDotBelow => '𐽆',
Sogdian::CombiningTwoDotsBelow => '𐽇',
Sogdian::CombiningDotAbove => '𐽈',
Sogdian::CombiningTwoDotsAbove => '𐽉',
Sogdian::CombiningCurveAbove => '𐽊',
Sogdian::CombiningCurveBelow => '𐽋',
Sogdian::CombiningHookAbove => '𐽌',
Sogdian::CombiningHookBelow => '𐽍',
Sogdian::CombiningLongHookBelow => '𐽎',
Sogdian::CombiningReshBelow => '𐽏',
Sogdian::CombiningStrokeBelow => '𐽐',
Sogdian::NumberOne => '𐽑',
Sogdian::NumberTen => '𐽒',
Sogdian::NumberTwenty => '𐽓',
Sogdian::NumberOneHundred => '𐽔',
Sogdian::PunctuationTwoVerticalBars => '𐽕',
Sogdian::PunctuationTwoVerticalBarsWithDots => '𐽖',
Sogdian::PunctuationCircleWithDot => '𐽗',
Sogdian::PunctuationTwoCirclesWithDots => '𐽘',
Sogdian::PunctuationHalfCircleWithDot => '𐽙',
}
}
}
impl std::convert::TryFrom<char> for Sogdian {
type Error = ();
fn try_from(c: char) -> Result<Self, Self::Error> {
match c {
'𐼰' => Ok(Sogdian::LetterAleph),
'𐼱' => Ok(Sogdian::LetterBeth),
'𐼲' => Ok(Sogdian::LetterGimel),
'𐼳' => Ok(Sogdian::LetterHe),
'𐼴' => Ok(Sogdian::LetterWaw),
'𐼵' => Ok(Sogdian::LetterZayin),
'𐼶' => Ok(Sogdian::LetterHeth),
'𐼷' => Ok(Sogdian::LetterYodh),
'𐼸' => Ok(Sogdian::LetterKaph),
'𐼹' => Ok(Sogdian::LetterLamedh),
'𐼺' => Ok(Sogdian::LetterMem),
'𐼻' => Ok(Sogdian::LetterNun),
'𐼼' => Ok(Sogdian::LetterSamekh),
'𐼽' => Ok(Sogdian::LetterAyin),
'𐼾' => Ok(Sogdian::LetterPe),
'𐼿' => Ok(Sogdian::LetterSadhe),
'𐽀' => Ok(Sogdian::LetterReshDashAyin),
'𐽁' => Ok(Sogdian::LetterShin),
'𐽂' => Ok(Sogdian::LetterTaw),
'𐽃' => Ok(Sogdian::LetterFeth),
'𐽄' => Ok(Sogdian::LetterLesh),
'𐽅' => Ok(Sogdian::IndependentShin),
'𐽆' => Ok(Sogdian::CombiningDotBelow),
'𐽇' => Ok(Sogdian::CombiningTwoDotsBelow),
'𐽈' => Ok(Sogdian::CombiningDotAbove),
'𐽉' => Ok(Sogdian::CombiningTwoDotsAbove),
'𐽊' => Ok(Sogdian::CombiningCurveAbove),
'𐽋' => Ok(Sogdian::CombiningCurveBelow),
'𐽌' => Ok(Sogdian::CombiningHookAbove),
'𐽍' => Ok(Sogdian::CombiningHookBelow),
'𐽎' => Ok(Sogdian::CombiningLongHookBelow),
'𐽏' => Ok(Sogdian::CombiningReshBelow),
'𐽐' => Ok(Sogdian::CombiningStrokeBelow),
'𐽑' => Ok(Sogdian::NumberOne),
'𐽒' => Ok(Sogdian::NumberTen),
'𐽓' => Ok(Sogdian::NumberTwenty),
'𐽔' => Ok(Sogdian::NumberOneHundred),
'𐽕' => Ok(Sogdian::PunctuationTwoVerticalBars),
'𐽖' => Ok(Sogdian::PunctuationTwoVerticalBarsWithDots),
'𐽗' => Ok(Sogdian::PunctuationCircleWithDot),
'𐽘' => Ok(Sogdian::PunctuationTwoCirclesWithDots),
'𐽙' => Ok(Sogdian::PunctuationHalfCircleWithDot),
_ => Err(()),
}
}
}
impl Into<u32> for Sogdian {
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 Sogdian {
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 Sogdian {
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 Sogdian {
pub fn new() -> Self {
Sogdian::LetterAleph
}
pub fn name(&self) -> String {
let s = std::format!("Sogdian{:#?}", self);
string_morph::to_sentence_case(&s)
}
}