#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum Gothic {
LetterAhsa,
LetterBairkan,
LetterGiba,
LetterDags,
LetterAihvus,
LetterQairthra,
LetterIuja,
LetterHagl,
LetterThiuth,
LetterEis,
LetterKusma,
LetterLagus,
LetterManna,
LetterNauths,
LetterJer,
LetterUrus,
LetterPairthra,
LetterNinety,
LetterRaida,
LetterSauil,
LetterTeiws,
LetterWinja,
LetterFaihu,
LetterIggws,
LetterHwair,
LetterOthal,
LetterNineHundred,
}
impl Into<char> for Gothic {
fn into(self) -> char {
match self {
Gothic::LetterAhsa => '𐌰',
Gothic::LetterBairkan => '𐌱',
Gothic::LetterGiba => '𐌲',
Gothic::LetterDags => '𐌳',
Gothic::LetterAihvus => '𐌴',
Gothic::LetterQairthra => '𐌵',
Gothic::LetterIuja => '𐌶',
Gothic::LetterHagl => '𐌷',
Gothic::LetterThiuth => '𐌸',
Gothic::LetterEis => '𐌹',
Gothic::LetterKusma => '𐌺',
Gothic::LetterLagus => '𐌻',
Gothic::LetterManna => '𐌼',
Gothic::LetterNauths => '𐌽',
Gothic::LetterJer => '𐌾',
Gothic::LetterUrus => '𐌿',
Gothic::LetterPairthra => '𐍀',
Gothic::LetterNinety => '𐍁',
Gothic::LetterRaida => '𐍂',
Gothic::LetterSauil => '𐍃',
Gothic::LetterTeiws => '𐍄',
Gothic::LetterWinja => '𐍅',
Gothic::LetterFaihu => '𐍆',
Gothic::LetterIggws => '𐍇',
Gothic::LetterHwair => '𐍈',
Gothic::LetterOthal => '𐍉',
Gothic::LetterNineHundred => '𐍊',
}
}
}
impl std::convert::TryFrom<char> for Gothic {
type Error = ();
fn try_from(c: char) -> Result<Self, Self::Error> {
match c {
'𐌰' => Ok(Gothic::LetterAhsa),
'𐌱' => Ok(Gothic::LetterBairkan),
'𐌲' => Ok(Gothic::LetterGiba),
'𐌳' => Ok(Gothic::LetterDags),
'𐌴' => Ok(Gothic::LetterAihvus),
'𐌵' => Ok(Gothic::LetterQairthra),
'𐌶' => Ok(Gothic::LetterIuja),
'𐌷' => Ok(Gothic::LetterHagl),
'𐌸' => Ok(Gothic::LetterThiuth),
'𐌹' => Ok(Gothic::LetterEis),
'𐌺' => Ok(Gothic::LetterKusma),
'𐌻' => Ok(Gothic::LetterLagus),
'𐌼' => Ok(Gothic::LetterManna),
'𐌽' => Ok(Gothic::LetterNauths),
'𐌾' => Ok(Gothic::LetterJer),
'𐌿' => Ok(Gothic::LetterUrus),
'𐍀' => Ok(Gothic::LetterPairthra),
'𐍁' => Ok(Gothic::LetterNinety),
'𐍂' => Ok(Gothic::LetterRaida),
'𐍃' => Ok(Gothic::LetterSauil),
'𐍄' => Ok(Gothic::LetterTeiws),
'𐍅' => Ok(Gothic::LetterWinja),
'𐍆' => Ok(Gothic::LetterFaihu),
'𐍇' => Ok(Gothic::LetterIggws),
'𐍈' => Ok(Gothic::LetterHwair),
'𐍉' => Ok(Gothic::LetterOthal),
'𐍊' => Ok(Gothic::LetterNineHundred),
_ => Err(()),
}
}
}
impl Into<u32> for Gothic {
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 Gothic {
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 Gothic {
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 Gothic {
pub fn new() -> Self {
Gothic::LetterAhsa
}
pub fn name(&self) -> String {
let s = std::format!("Gothic{:#?}", self);
string_morph::to_sentence_case(&s)
}
}