#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum Kharoshthi {
LetterA,
VowelSignI,
VowelSignU,
VowelSignVocalicR,
VowelSignE,
VowelSignO,
VowelLengthMark,
SignDoubleRingBelow,
SignAnusvara,
SignVisarga,
LetterKa,
LetterKha,
LetterGa,
LetterGha,
LetterCa,
LetterCha,
LetterJa,
LetterNya,
LetterTta,
LetterTtha,
LetterDda,
LetterDdha,
LetterNna,
LetterTa,
LetterTha,
LetterDa,
LetterDha,
LetterNa,
LetterPa,
LetterPha,
LetterBa,
LetterBha,
LetterMa,
LetterYa,
LetterRa,
LetterLa,
LetterVa,
LetterSha,
LetterSsa,
LetterSa,
LetterZa,
LetterHa,
LetterKka,
LetterTttha,
LetterTtta,
LetterVha,
SignBarAbove,
SignCauda,
SignDotBelow,
Virama,
DigitOne,
DigitTwo,
DigitThree,
DigitFour,
NumberTen,
NumberTwenty,
NumberOneHundred,
NumberOneThousand,
FractionOneHalf,
PunctuationDot,
PunctuationSmallCircle,
PunctuationCircle,
PunctuationCrescentBar,
PunctuationMangalam,
PunctuationLotus,
PunctuationDanda,
PunctuationDoubleDanda,
PunctuationLines,
}
impl Into<char> for Kharoshthi {
fn into(self) -> char {
match self {
Kharoshthi::LetterA => '𐨀',
Kharoshthi::VowelSignI => '𐨁',
Kharoshthi::VowelSignU => '𐨂',
Kharoshthi::VowelSignVocalicR => '𐨃',
Kharoshthi::VowelSignE => '𐨅',
Kharoshthi::VowelSignO => '𐨆',
Kharoshthi::VowelLengthMark => '𐨌',
Kharoshthi::SignDoubleRingBelow => '𐨍',
Kharoshthi::SignAnusvara => '𐨎',
Kharoshthi::SignVisarga => '𐨏',
Kharoshthi::LetterKa => '𐨐',
Kharoshthi::LetterKha => '𐨑',
Kharoshthi::LetterGa => '𐨒',
Kharoshthi::LetterGha => '𐨓',
Kharoshthi::LetterCa => '𐨕',
Kharoshthi::LetterCha => '𐨖',
Kharoshthi::LetterJa => '𐨗',
Kharoshthi::LetterNya => '𐨙',
Kharoshthi::LetterTta => '𐨚',
Kharoshthi::LetterTtha => '𐨛',
Kharoshthi::LetterDda => '𐨜',
Kharoshthi::LetterDdha => '𐨝',
Kharoshthi::LetterNna => '𐨞',
Kharoshthi::LetterTa => '𐨟',
Kharoshthi::LetterTha => '𐨠',
Kharoshthi::LetterDa => '𐨡',
Kharoshthi::LetterDha => '𐨢',
Kharoshthi::LetterNa => '𐨣',
Kharoshthi::LetterPa => '𐨤',
Kharoshthi::LetterPha => '𐨥',
Kharoshthi::LetterBa => '𐨦',
Kharoshthi::LetterBha => '𐨧',
Kharoshthi::LetterMa => '𐨨',
Kharoshthi::LetterYa => '𐨩',
Kharoshthi::LetterRa => '𐨪',
Kharoshthi::LetterLa => '𐨫',
Kharoshthi::LetterVa => '𐨬',
Kharoshthi::LetterSha => '𐨭',
Kharoshthi::LetterSsa => '𐨮',
Kharoshthi::LetterSa => '𐨯',
Kharoshthi::LetterZa => '𐨰',
Kharoshthi::LetterHa => '𐨱',
Kharoshthi::LetterKka => '𐨲',
Kharoshthi::LetterTttha => '𐨳',
Kharoshthi::LetterTtta => '𐨴',
Kharoshthi::LetterVha => '𐨵',
Kharoshthi::SignBarAbove => '𐨸',
Kharoshthi::SignCauda => '𐨹',
Kharoshthi::SignDotBelow => '𐨺',
Kharoshthi::Virama => '𐨿',
Kharoshthi::DigitOne => '𐩀',
Kharoshthi::DigitTwo => '𐩁',
Kharoshthi::DigitThree => '𐩂',
Kharoshthi::DigitFour => '𐩃',
Kharoshthi::NumberTen => '𐩄',
Kharoshthi::NumberTwenty => '𐩅',
Kharoshthi::NumberOneHundred => '𐩆',
Kharoshthi::NumberOneThousand => '𐩇',
Kharoshthi::FractionOneHalf => '𐩈',
Kharoshthi::PunctuationDot => '𐩐',
Kharoshthi::PunctuationSmallCircle => '𐩑',
Kharoshthi::PunctuationCircle => '𐩒',
Kharoshthi::PunctuationCrescentBar => '𐩓',
Kharoshthi::PunctuationMangalam => '𐩔',
Kharoshthi::PunctuationLotus => '𐩕',
Kharoshthi::PunctuationDanda => '𐩖',
Kharoshthi::PunctuationDoubleDanda => '𐩗',
Kharoshthi::PunctuationLines => '𐩘',
}
}
}
impl std::convert::TryFrom<char> for Kharoshthi {
type Error = ();
fn try_from(c: char) -> Result<Self, Self::Error> {
match c {
'𐨀' => Ok(Kharoshthi::LetterA),
'𐨁' => Ok(Kharoshthi::VowelSignI),
'𐨂' => Ok(Kharoshthi::VowelSignU),
'𐨃' => Ok(Kharoshthi::VowelSignVocalicR),
'𐨅' => Ok(Kharoshthi::VowelSignE),
'𐨆' => Ok(Kharoshthi::VowelSignO),
'𐨌' => Ok(Kharoshthi::VowelLengthMark),
'𐨍' => Ok(Kharoshthi::SignDoubleRingBelow),
'𐨎' => Ok(Kharoshthi::SignAnusvara),
'𐨏' => Ok(Kharoshthi::SignVisarga),
'𐨐' => Ok(Kharoshthi::LetterKa),
'𐨑' => Ok(Kharoshthi::LetterKha),
'𐨒' => Ok(Kharoshthi::LetterGa),
'𐨓' => Ok(Kharoshthi::LetterGha),
'𐨕' => Ok(Kharoshthi::LetterCa),
'𐨖' => Ok(Kharoshthi::LetterCha),
'𐨗' => Ok(Kharoshthi::LetterJa),
'𐨙' => Ok(Kharoshthi::LetterNya),
'𐨚' => Ok(Kharoshthi::LetterTta),
'𐨛' => Ok(Kharoshthi::LetterTtha),
'𐨜' => Ok(Kharoshthi::LetterDda),
'𐨝' => Ok(Kharoshthi::LetterDdha),
'𐨞' => Ok(Kharoshthi::LetterNna),
'𐨟' => Ok(Kharoshthi::LetterTa),
'𐨠' => Ok(Kharoshthi::LetterTha),
'𐨡' => Ok(Kharoshthi::LetterDa),
'𐨢' => Ok(Kharoshthi::LetterDha),
'𐨣' => Ok(Kharoshthi::LetterNa),
'𐨤' => Ok(Kharoshthi::LetterPa),
'𐨥' => Ok(Kharoshthi::LetterPha),
'𐨦' => Ok(Kharoshthi::LetterBa),
'𐨧' => Ok(Kharoshthi::LetterBha),
'𐨨' => Ok(Kharoshthi::LetterMa),
'𐨩' => Ok(Kharoshthi::LetterYa),
'𐨪' => Ok(Kharoshthi::LetterRa),
'𐨫' => Ok(Kharoshthi::LetterLa),
'𐨬' => Ok(Kharoshthi::LetterVa),
'𐨭' => Ok(Kharoshthi::LetterSha),
'𐨮' => Ok(Kharoshthi::LetterSsa),
'𐨯' => Ok(Kharoshthi::LetterSa),
'𐨰' => Ok(Kharoshthi::LetterZa),
'𐨱' => Ok(Kharoshthi::LetterHa),
'𐨲' => Ok(Kharoshthi::LetterKka),
'𐨳' => Ok(Kharoshthi::LetterTttha),
'𐨴' => Ok(Kharoshthi::LetterTtta),
'𐨵' => Ok(Kharoshthi::LetterVha),
'𐨸' => Ok(Kharoshthi::SignBarAbove),
'𐨹' => Ok(Kharoshthi::SignCauda),
'𐨺' => Ok(Kharoshthi::SignDotBelow),
'𐨿' => Ok(Kharoshthi::Virama),
'𐩀' => Ok(Kharoshthi::DigitOne),
'𐩁' => Ok(Kharoshthi::DigitTwo),
'𐩂' => Ok(Kharoshthi::DigitThree),
'𐩃' => Ok(Kharoshthi::DigitFour),
'𐩄' => Ok(Kharoshthi::NumberTen),
'𐩅' => Ok(Kharoshthi::NumberTwenty),
'𐩆' => Ok(Kharoshthi::NumberOneHundred),
'𐩇' => Ok(Kharoshthi::NumberOneThousand),
'𐩈' => Ok(Kharoshthi::FractionOneHalf),
'𐩐' => Ok(Kharoshthi::PunctuationDot),
'𐩑' => Ok(Kharoshthi::PunctuationSmallCircle),
'𐩒' => Ok(Kharoshthi::PunctuationCircle),
'𐩓' => Ok(Kharoshthi::PunctuationCrescentBar),
'𐩔' => Ok(Kharoshthi::PunctuationMangalam),
'𐩕' => Ok(Kharoshthi::PunctuationLotus),
'𐩖' => Ok(Kharoshthi::PunctuationDanda),
'𐩗' => Ok(Kharoshthi::PunctuationDoubleDanda),
'𐩘' => Ok(Kharoshthi::PunctuationLines),
_ => Err(()),
}
}
}
impl Into<u32> for Kharoshthi {
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 Kharoshthi {
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 Kharoshthi {
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 Kharoshthi {
pub fn new() -> Self {
Kharoshthi::LetterA
}
pub fn name(&self) -> String {
let s = std::format!("Kharoshthi{:#?}", self);
string_morph::to_sentence_case(&s)
}
}