unicode_types/generated/
ugaritic.rs

1
2/// An enum to represent all characters in the Ugaritic block.
3#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
4pub enum Ugaritic {
5    /// \u{10380}: '𐎀'
6    LetterAlpa,
7    /// \u{10381}: '𐎁'
8    LetterBeta,
9    /// \u{10382}: '𐎂'
10    LetterGamla,
11    /// \u{10383}: '𐎃'
12    LetterKha,
13    /// \u{10384}: '𐎄'
14    LetterDelta,
15    /// \u{10385}: '𐎅'
16    LetterHo,
17    /// \u{10386}: '𐎆'
18    LetterWo,
19    /// \u{10387}: '𐎇'
20    LetterZeta,
21    /// \u{10388}: '𐎈'
22    LetterHota,
23    /// \u{10389}: '𐎉'
24    LetterTet,
25    /// \u{1038a}: '𐎊'
26    LetterYod,
27    /// \u{1038b}: '𐎋'
28    LetterKaf,
29    /// \u{1038c}: '𐎌'
30    LetterShin,
31    /// \u{1038d}: '𐎍'
32    LetterLamda,
33    /// \u{1038e}: '𐎎'
34    LetterMem,
35    /// \u{1038f}: '𐎏'
36    LetterDhal,
37    /// \u{10390}: '𐎐'
38    LetterNun,
39    /// \u{10391}: '𐎑'
40    LetterZu,
41    /// \u{10392}: '𐎒'
42    LetterSamka,
43    /// \u{10393}: '𐎓'
44    LetterAin,
45    /// \u{10394}: '𐎔'
46    LetterPu,
47    /// \u{10395}: '𐎕'
48    LetterSade,
49    /// \u{10396}: '𐎖'
50    LetterQopa,
51    /// \u{10397}: '𐎗'
52    LetterRasha,
53    /// \u{10398}: '𐎘'
54    LetterThanna,
55    /// \u{10399}: '𐎙'
56    LetterGhain,
57    /// \u{1039a}: '𐎚'
58    LetterTo,
59    /// \u{1039b}: '𐎛'
60    LetterI,
61    /// \u{1039c}: '𐎜'
62    LetterU,
63    /// \u{1039d}: '𐎝'
64    LetterSsu,
65}
66
67impl Into<char> for Ugaritic {
68    fn into(self) -> char {
69        match self {
70            Ugaritic::LetterAlpa => '𐎀',
71            Ugaritic::LetterBeta => '𐎁',
72            Ugaritic::LetterGamla => '𐎂',
73            Ugaritic::LetterKha => '𐎃',
74            Ugaritic::LetterDelta => '𐎄',
75            Ugaritic::LetterHo => '𐎅',
76            Ugaritic::LetterWo => '𐎆',
77            Ugaritic::LetterZeta => '𐎇',
78            Ugaritic::LetterHota => '𐎈',
79            Ugaritic::LetterTet => '𐎉',
80            Ugaritic::LetterYod => '𐎊',
81            Ugaritic::LetterKaf => '𐎋',
82            Ugaritic::LetterShin => '𐎌',
83            Ugaritic::LetterLamda => '𐎍',
84            Ugaritic::LetterMem => '𐎎',
85            Ugaritic::LetterDhal => '𐎏',
86            Ugaritic::LetterNun => '𐎐',
87            Ugaritic::LetterZu => '𐎑',
88            Ugaritic::LetterSamka => '𐎒',
89            Ugaritic::LetterAin => '𐎓',
90            Ugaritic::LetterPu => '𐎔',
91            Ugaritic::LetterSade => '𐎕',
92            Ugaritic::LetterQopa => '𐎖',
93            Ugaritic::LetterRasha => '𐎗',
94            Ugaritic::LetterThanna => '𐎘',
95            Ugaritic::LetterGhain => '𐎙',
96            Ugaritic::LetterTo => '𐎚',
97            Ugaritic::LetterI => '𐎛',
98            Ugaritic::LetterU => '𐎜',
99            Ugaritic::LetterSsu => '𐎝',
100        }
101    }
102}
103
104impl std::convert::TryFrom<char> for Ugaritic {
105    type Error = ();
106    fn try_from(c: char) -> Result<Self, Self::Error> {
107        match c {
108            '𐎀' => Ok(Ugaritic::LetterAlpa),
109            '𐎁' => Ok(Ugaritic::LetterBeta),
110            '𐎂' => Ok(Ugaritic::LetterGamla),
111            '𐎃' => Ok(Ugaritic::LetterKha),
112            '𐎄' => Ok(Ugaritic::LetterDelta),
113            '𐎅' => Ok(Ugaritic::LetterHo),
114            '𐎆' => Ok(Ugaritic::LetterWo),
115            '𐎇' => Ok(Ugaritic::LetterZeta),
116            '𐎈' => Ok(Ugaritic::LetterHota),
117            '𐎉' => Ok(Ugaritic::LetterTet),
118            '𐎊' => Ok(Ugaritic::LetterYod),
119            '𐎋' => Ok(Ugaritic::LetterKaf),
120            '𐎌' => Ok(Ugaritic::LetterShin),
121            '𐎍' => Ok(Ugaritic::LetterLamda),
122            '𐎎' => Ok(Ugaritic::LetterMem),
123            '𐎏' => Ok(Ugaritic::LetterDhal),
124            '𐎐' => Ok(Ugaritic::LetterNun),
125            '𐎑' => Ok(Ugaritic::LetterZu),
126            '𐎒' => Ok(Ugaritic::LetterSamka),
127            '𐎓' => Ok(Ugaritic::LetterAin),
128            '𐎔' => Ok(Ugaritic::LetterPu),
129            '𐎕' => Ok(Ugaritic::LetterSade),
130            '𐎖' => Ok(Ugaritic::LetterQopa),
131            '𐎗' => Ok(Ugaritic::LetterRasha),
132            '𐎘' => Ok(Ugaritic::LetterThanna),
133            '𐎙' => Ok(Ugaritic::LetterGhain),
134            '𐎚' => Ok(Ugaritic::LetterTo),
135            '𐎛' => Ok(Ugaritic::LetterI),
136            '𐎜' => Ok(Ugaritic::LetterU),
137            '𐎝' => Ok(Ugaritic::LetterSsu),
138            _ => Err(()),
139        }
140    }
141}
142
143impl Into<u32> for Ugaritic {
144    fn into(self) -> u32 {
145        let c: char = self.into();
146        let hex = c
147            .escape_unicode()
148            .to_string()
149            .replace("\\u{", "")
150            .replace("}", "");
151        u32::from_str_radix(&hex, 16).unwrap()
152    }
153}
154
155impl std::convert::TryFrom<u32> for Ugaritic {
156    type Error = ();
157    fn try_from(u: u32) -> Result<Self, Self::Error> {
158        if let Ok(c) = char::try_from(u) {
159            Self::try_from(c)
160        } else {
161            Err(())
162        }
163    }
164}
165
166impl Iterator for Ugaritic {
167    type Item = Self;
168    fn next(&mut self) -> Option<Self> {
169        let index: u32 = (*self).into();
170        use std::convert::TryFrom;
171        Self::try_from(index + 1).ok()
172    }
173}
174
175impl Ugaritic {
176    /// The character with the lowest index in this unicode block
177    pub fn new() -> Self {
178        Ugaritic::LetterAlpa
179    }
180
181    /// The character's name, in sentence case
182    pub fn name(&self) -> String {
183        let s = std::format!("Ugaritic{:#?}", self);
184        string_morph::to_sentence_case(&s)
185    }
186}