mod constants {
pub const SIGN_CANDRABINDU: char = '𑂀';
pub const SIGN_ANUSVARA: char = '𑂁';
pub const SIGN_VISARGA: char = '𑂂';
pub const LETTER_A: char = '𑂃';
pub const LETTER_AA: char = '𑂄';
pub const LETTER_I: char = '𑂅';
pub const LETTER_II: char = '𑂆';
pub const LETTER_U: char = '𑂇';
pub const LETTER_UU: char = '𑂈';
pub const LETTER_E: char = '𑂉';
pub const LETTER_AI: char = '𑂊';
pub const LETTER_O: char = '𑂋';
pub const LETTER_AU: char = '𑂌';
pub const LETTER_KA: char = '𑂍';
pub const LETTER_KHA: char = '𑂎';
pub const LETTER_GA: char = '𑂏';
pub const LETTER_GHA: char = '𑂐';
pub const LETTER_NGA: char = '𑂑';
pub const LETTER_CA: char = '𑂒';
pub const LETTER_CHA: char = '𑂓';
pub const LETTER_JA: char = '𑂔';
pub const LETTER_JHA: char = '𑂕';
pub const LETTER_NYA: char = '𑂖';
pub const LETTER_TTA: char = '𑂗';
pub const LETTER_TTHA: char = '𑂘';
pub const LETTER_DDA: char = '𑂙';
pub const LETTER_DDDHA: char = '𑂚';
pub const LETTER_DDHA: char = '𑂛';
pub const LETTER_RHA: char = '𑂜';
pub const LETTER_NNA: char = '𑂝';
pub const LETTER_TA: char = '𑂞';
pub const LETTER_THA: char = '𑂟';
pub const LETTER_DA: char = '𑂠';
pub const LETTER_DHA: char = '𑂡';
pub const LETTER_NA: char = '𑂢';
pub const LETTER_PA: char = '𑂣';
pub const LETTER_PHA: char = '𑂤';
pub const LETTER_BA: char = '𑂥';
pub const LETTER_BHA: char = '𑂦';
pub const LETTER_MA: char = '𑂧';
pub const LETTER_YA: char = '𑂨';
pub const LETTER_RA: char = '𑂩';
pub const LETTER_LA: char = '𑂪';
pub const LETTER_VA: char = '𑂫';
pub const LETTER_SHA: char = '𑂬';
pub const LETTER_SSA: char = '𑂭';
pub const LETTER_SA: char = '𑂮';
pub const LETTER_HA: char = '𑂯';
pub const VOWEL_SIGN_AA: char = '𑂰';
pub const VOWEL_SIGN_I: char = '𑂱';
pub const VOWEL_SIGN_II: char = '𑂲';
pub const VOWEL_SIGN_U: char = '𑂳';
pub const VOWEL_SIGN_UU: char = '𑂴';
pub const VOWEL_SIGN_E: char = '𑂵';
pub const VOWEL_SIGN_AI: char = '𑂶';
pub const VOWEL_SIGN_O: char = '𑂷';
pub const VOWEL_SIGN_AU: char = '𑂸';
pub const SIGN_VIRAMA: char = '𑂹';
pub const SIGN_NUKTA: char = '𑂺';
pub const ABBREVIATION_SIGN: char = '𑂻';
pub const ENUMERATION_SIGN: char = '𑂼';
pub const NUMBER_SIGN: char = '';
pub const SECTION_MARK: char = '𑂾';
pub const DOUBLE_SECTION_MARK: char = '𑂿';
pub const DANDA: char = '𑃀';
pub const DOUBLE_DANDA: char = '𑃁';
pub const NUMBER_SIGN_ABOVE: char = '';
}
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum Kaithi {
SignCandrabindu,
SignAnusvara,
SignVisarga,
LetterA,
LetterAa,
LetterI,
LetterIi,
LetterU,
LetterUu,
LetterE,
LetterAi,
LetterO,
LetterAu,
LetterKa,
LetterKha,
LetterGa,
LetterGha,
LetterNga,
LetterCa,
LetterCha,
LetterJa,
LetterJha,
LetterNya,
LetterTta,
LetterTtha,
LetterDda,
LetterDddha,
LetterDdha,
LetterRha,
LetterNna,
LetterTa,
LetterTha,
LetterDa,
LetterDha,
LetterNa,
LetterPa,
LetterPha,
LetterBa,
LetterBha,
LetterMa,
LetterYa,
LetterRa,
LetterLa,
LetterVa,
LetterSha,
LetterSsa,
LetterSa,
LetterHa,
VowelSignAa,
VowelSignI,
VowelSignIi,
VowelSignU,
VowelSignUu,
VowelSignE,
VowelSignAi,
VowelSignO,
VowelSignAu,
SignVirama,
SignNukta,
AbbreviationSign,
EnumerationSign,
NumberSign,
SectionMark,
DoubleSectionMark,
Danda,
DoubleDanda,
NumberSignAbove,
}
impl Into<char> for Kaithi {
fn into(self) -> char {
use constants::*;
match self {
Kaithi::SignCandrabindu => SIGN_CANDRABINDU,
Kaithi::SignAnusvara => SIGN_ANUSVARA,
Kaithi::SignVisarga => SIGN_VISARGA,
Kaithi::LetterA => LETTER_A,
Kaithi::LetterAa => LETTER_AA,
Kaithi::LetterI => LETTER_I,
Kaithi::LetterIi => LETTER_II,
Kaithi::LetterU => LETTER_U,
Kaithi::LetterUu => LETTER_UU,
Kaithi::LetterE => LETTER_E,
Kaithi::LetterAi => LETTER_AI,
Kaithi::LetterO => LETTER_O,
Kaithi::LetterAu => LETTER_AU,
Kaithi::LetterKa => LETTER_KA,
Kaithi::LetterKha => LETTER_KHA,
Kaithi::LetterGa => LETTER_GA,
Kaithi::LetterGha => LETTER_GHA,
Kaithi::LetterNga => LETTER_NGA,
Kaithi::LetterCa => LETTER_CA,
Kaithi::LetterCha => LETTER_CHA,
Kaithi::LetterJa => LETTER_JA,
Kaithi::LetterJha => LETTER_JHA,
Kaithi::LetterNya => LETTER_NYA,
Kaithi::LetterTta => LETTER_TTA,
Kaithi::LetterTtha => LETTER_TTHA,
Kaithi::LetterDda => LETTER_DDA,
Kaithi::LetterDddha => LETTER_DDDHA,
Kaithi::LetterDdha => LETTER_DDHA,
Kaithi::LetterRha => LETTER_RHA,
Kaithi::LetterNna => LETTER_NNA,
Kaithi::LetterTa => LETTER_TA,
Kaithi::LetterTha => LETTER_THA,
Kaithi::LetterDa => LETTER_DA,
Kaithi::LetterDha => LETTER_DHA,
Kaithi::LetterNa => LETTER_NA,
Kaithi::LetterPa => LETTER_PA,
Kaithi::LetterPha => LETTER_PHA,
Kaithi::LetterBa => LETTER_BA,
Kaithi::LetterBha => LETTER_BHA,
Kaithi::LetterMa => LETTER_MA,
Kaithi::LetterYa => LETTER_YA,
Kaithi::LetterRa => LETTER_RA,
Kaithi::LetterLa => LETTER_LA,
Kaithi::LetterVa => LETTER_VA,
Kaithi::LetterSha => LETTER_SHA,
Kaithi::LetterSsa => LETTER_SSA,
Kaithi::LetterSa => LETTER_SA,
Kaithi::LetterHa => LETTER_HA,
Kaithi::VowelSignAa => VOWEL_SIGN_AA,
Kaithi::VowelSignI => VOWEL_SIGN_I,
Kaithi::VowelSignIi => VOWEL_SIGN_II,
Kaithi::VowelSignU => VOWEL_SIGN_U,
Kaithi::VowelSignUu => VOWEL_SIGN_UU,
Kaithi::VowelSignE => VOWEL_SIGN_E,
Kaithi::VowelSignAi => VOWEL_SIGN_AI,
Kaithi::VowelSignO => VOWEL_SIGN_O,
Kaithi::VowelSignAu => VOWEL_SIGN_AU,
Kaithi::SignVirama => SIGN_VIRAMA,
Kaithi::SignNukta => SIGN_NUKTA,
Kaithi::AbbreviationSign => ABBREVIATION_SIGN,
Kaithi::EnumerationSign => ENUMERATION_SIGN,
Kaithi::NumberSign => NUMBER_SIGN,
Kaithi::SectionMark => SECTION_MARK,
Kaithi::DoubleSectionMark => DOUBLE_SECTION_MARK,
Kaithi::Danda => DANDA,
Kaithi::DoubleDanda => DOUBLE_DANDA,
Kaithi::NumberSignAbove => NUMBER_SIGN_ABOVE,
}
}
}
impl std::convert::TryFrom<char> for Kaithi {
type Error = ();
fn try_from(c: char) -> Result<Self, Self::Error> {
use constants::*;
match c {
SIGN_CANDRABINDU => Ok(Kaithi::SignCandrabindu),
SIGN_ANUSVARA => Ok(Kaithi::SignAnusvara),
SIGN_VISARGA => Ok(Kaithi::SignVisarga),
LETTER_A => Ok(Kaithi::LetterA),
LETTER_AA => Ok(Kaithi::LetterAa),
LETTER_I => Ok(Kaithi::LetterI),
LETTER_II => Ok(Kaithi::LetterIi),
LETTER_U => Ok(Kaithi::LetterU),
LETTER_UU => Ok(Kaithi::LetterUu),
LETTER_E => Ok(Kaithi::LetterE),
LETTER_AI => Ok(Kaithi::LetterAi),
LETTER_O => Ok(Kaithi::LetterO),
LETTER_AU => Ok(Kaithi::LetterAu),
LETTER_KA => Ok(Kaithi::LetterKa),
LETTER_KHA => Ok(Kaithi::LetterKha),
LETTER_GA => Ok(Kaithi::LetterGa),
LETTER_GHA => Ok(Kaithi::LetterGha),
LETTER_NGA => Ok(Kaithi::LetterNga),
LETTER_CA => Ok(Kaithi::LetterCa),
LETTER_CHA => Ok(Kaithi::LetterCha),
LETTER_JA => Ok(Kaithi::LetterJa),
LETTER_JHA => Ok(Kaithi::LetterJha),
LETTER_NYA => Ok(Kaithi::LetterNya),
LETTER_TTA => Ok(Kaithi::LetterTta),
LETTER_TTHA => Ok(Kaithi::LetterTtha),
LETTER_DDA => Ok(Kaithi::LetterDda),
LETTER_DDDHA => Ok(Kaithi::LetterDddha),
LETTER_DDHA => Ok(Kaithi::LetterDdha),
LETTER_RHA => Ok(Kaithi::LetterRha),
LETTER_NNA => Ok(Kaithi::LetterNna),
LETTER_TA => Ok(Kaithi::LetterTa),
LETTER_THA => Ok(Kaithi::LetterTha),
LETTER_DA => Ok(Kaithi::LetterDa),
LETTER_DHA => Ok(Kaithi::LetterDha),
LETTER_NA => Ok(Kaithi::LetterNa),
LETTER_PA => Ok(Kaithi::LetterPa),
LETTER_PHA => Ok(Kaithi::LetterPha),
LETTER_BA => Ok(Kaithi::LetterBa),
LETTER_BHA => Ok(Kaithi::LetterBha),
LETTER_MA => Ok(Kaithi::LetterMa),
LETTER_YA => Ok(Kaithi::LetterYa),
LETTER_RA => Ok(Kaithi::LetterRa),
LETTER_LA => Ok(Kaithi::LetterLa),
LETTER_VA => Ok(Kaithi::LetterVa),
LETTER_SHA => Ok(Kaithi::LetterSha),
LETTER_SSA => Ok(Kaithi::LetterSsa),
LETTER_SA => Ok(Kaithi::LetterSa),
LETTER_HA => Ok(Kaithi::LetterHa),
VOWEL_SIGN_AA => Ok(Kaithi::VowelSignAa),
VOWEL_SIGN_I => Ok(Kaithi::VowelSignI),
VOWEL_SIGN_II => Ok(Kaithi::VowelSignIi),
VOWEL_SIGN_U => Ok(Kaithi::VowelSignU),
VOWEL_SIGN_UU => Ok(Kaithi::VowelSignUu),
VOWEL_SIGN_E => Ok(Kaithi::VowelSignE),
VOWEL_SIGN_AI => Ok(Kaithi::VowelSignAi),
VOWEL_SIGN_O => Ok(Kaithi::VowelSignO),
VOWEL_SIGN_AU => Ok(Kaithi::VowelSignAu),
SIGN_VIRAMA => Ok(Kaithi::SignVirama),
SIGN_NUKTA => Ok(Kaithi::SignNukta),
ABBREVIATION_SIGN => Ok(Kaithi::AbbreviationSign),
ENUMERATION_SIGN => Ok(Kaithi::EnumerationSign),
NUMBER_SIGN => Ok(Kaithi::NumberSign),
SECTION_MARK => Ok(Kaithi::SectionMark),
DOUBLE_SECTION_MARK => Ok(Kaithi::DoubleSectionMark),
DANDA => Ok(Kaithi::Danda),
DOUBLE_DANDA => Ok(Kaithi::DoubleDanda),
NUMBER_SIGN_ABOVE => Ok(Kaithi::NumberSignAbove),
_ => Err(()),
}
}
}
impl Into<u32> for Kaithi {
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 Kaithi {
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 Kaithi {
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 Kaithi {
pub fn new() -> Self {
Kaithi::SignCandrabindu
}
pub fn name(&self) -> &str {
match self {
Kaithi::SignCandrabindu => "kaithi sign candrabindu",
Kaithi::SignAnusvara => "kaithi sign anusvara",
Kaithi::SignVisarga => "kaithi sign visarga",
Kaithi::LetterA => "kaithi letter a",
Kaithi::LetterAa => "kaithi letter aa",
Kaithi::LetterI => "kaithi letter i",
Kaithi::LetterIi => "kaithi letter ii",
Kaithi::LetterU => "kaithi letter u",
Kaithi::LetterUu => "kaithi letter uu",
Kaithi::LetterE => "kaithi letter e",
Kaithi::LetterAi => "kaithi letter ai",
Kaithi::LetterO => "kaithi letter o",
Kaithi::LetterAu => "kaithi letter au",
Kaithi::LetterKa => "kaithi letter ka",
Kaithi::LetterKha => "kaithi letter kha",
Kaithi::LetterGa => "kaithi letter ga",
Kaithi::LetterGha => "kaithi letter gha",
Kaithi::LetterNga => "kaithi letter nga",
Kaithi::LetterCa => "kaithi letter ca",
Kaithi::LetterCha => "kaithi letter cha",
Kaithi::LetterJa => "kaithi letter ja",
Kaithi::LetterJha => "kaithi letter jha",
Kaithi::LetterNya => "kaithi letter nya",
Kaithi::LetterTta => "kaithi letter tta",
Kaithi::LetterTtha => "kaithi letter ttha",
Kaithi::LetterDda => "kaithi letter dda",
Kaithi::LetterDddha => "kaithi letter dddha",
Kaithi::LetterDdha => "kaithi letter ddha",
Kaithi::LetterRha => "kaithi letter rha",
Kaithi::LetterNna => "kaithi letter nna",
Kaithi::LetterTa => "kaithi letter ta",
Kaithi::LetterTha => "kaithi letter tha",
Kaithi::LetterDa => "kaithi letter da",
Kaithi::LetterDha => "kaithi letter dha",
Kaithi::LetterNa => "kaithi letter na",
Kaithi::LetterPa => "kaithi letter pa",
Kaithi::LetterPha => "kaithi letter pha",
Kaithi::LetterBa => "kaithi letter ba",
Kaithi::LetterBha => "kaithi letter bha",
Kaithi::LetterMa => "kaithi letter ma",
Kaithi::LetterYa => "kaithi letter ya",
Kaithi::LetterRa => "kaithi letter ra",
Kaithi::LetterLa => "kaithi letter la",
Kaithi::LetterVa => "kaithi letter va",
Kaithi::LetterSha => "kaithi letter sha",
Kaithi::LetterSsa => "kaithi letter ssa",
Kaithi::LetterSa => "kaithi letter sa",
Kaithi::LetterHa => "kaithi letter ha",
Kaithi::VowelSignAa => "kaithi vowel sign aa",
Kaithi::VowelSignI => "kaithi vowel sign i",
Kaithi::VowelSignIi => "kaithi vowel sign ii",
Kaithi::VowelSignU => "kaithi vowel sign u",
Kaithi::VowelSignUu => "kaithi vowel sign uu",
Kaithi::VowelSignE => "kaithi vowel sign e",
Kaithi::VowelSignAi => "kaithi vowel sign ai",
Kaithi::VowelSignO => "kaithi vowel sign o",
Kaithi::VowelSignAu => "kaithi vowel sign au",
Kaithi::SignVirama => "kaithi sign virama",
Kaithi::SignNukta => "kaithi sign nukta",
Kaithi::AbbreviationSign => "kaithi abbreviation sign",
Kaithi::EnumerationSign => "kaithi enumeration sign",
Kaithi::NumberSign => "kaithi number sign",
Kaithi::SectionMark => "kaithi section mark",
Kaithi::DoubleSectionMark => "kaithi double section mark",
Kaithi::Danda => "kaithi danda",
Kaithi::DoubleDanda => "kaithi double danda",
Kaithi::NumberSignAbove => "kaithi number sign above",
}
}
}