1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382

/// An enum to represent all characters in the EthiopicExtended block.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum EthiopicExtended {
    /// \u{2d80}: 'ⶀ'
    EthiopicSyllableLoa,
    /// \u{2d81}: 'ⶁ'
    EthiopicSyllableMoa,
    /// \u{2d82}: 'ⶂ'
    EthiopicSyllableRoa,
    /// \u{2d83}: 'ⶃ'
    EthiopicSyllableSoa,
    /// \u{2d84}: 'ⶄ'
    EthiopicSyllableShoa,
    /// \u{2d85}: 'ⶅ'
    EthiopicSyllableBoa,
    /// \u{2d86}: 'ⶆ'
    EthiopicSyllableToa,
    /// \u{2d87}: 'ⶇ'
    EthiopicSyllableCoa,
    /// \u{2d88}: 'ⶈ'
    EthiopicSyllableNoa,
    /// \u{2d89}: 'ⶉ'
    EthiopicSyllableNyoa,
    /// \u{2d8a}: 'ⶊ'
    EthiopicSyllableGlottalOa,
    /// \u{2d8b}: 'ⶋ'
    EthiopicSyllableZoa,
    /// \u{2d8c}: 'ⶌ'
    EthiopicSyllableDoa,
    /// \u{2d8d}: 'ⶍ'
    EthiopicSyllableDdoa,
    /// \u{2d8e}: 'ⶎ'
    EthiopicSyllableJoa,
    /// \u{2d8f}: 'ⶏ'
    EthiopicSyllableThoa,
    /// \u{2d90}: 'ⶐ'
    EthiopicSyllableChoa,
    /// \u{2d91}: 'ⶑ'
    EthiopicSyllablePhoa,
    /// \u{2d92}: 'ⶒ'
    EthiopicSyllablePoa,
    /// \u{2d93}: 'ⶓ'
    EthiopicSyllableGgwa,
    /// \u{2d94}: 'ⶔ'
    EthiopicSyllableGgwi,
    /// \u{2d95}: 'ⶕ'
    EthiopicSyllableGgwee,
    /// \u{2d96}: 'ⶖ'
    EthiopicSyllableGgwe,
    /// \u{2da0}: 'ⶠ'
    EthiopicSyllableSsa,
    /// \u{2da1}: 'ⶡ'
    EthiopicSyllableSsu,
    /// \u{2da2}: 'ⶢ'
    EthiopicSyllableSsi,
    /// \u{2da3}: 'ⶣ'
    EthiopicSyllableSsaa,
    /// \u{2da4}: 'ⶤ'
    EthiopicSyllableSsee,
    /// \u{2da5}: 'ⶥ'
    EthiopicSyllableSse,
    /// \u{2da6}: 'ⶦ'
    EthiopicSyllableSso,
    /// \u{2da8}: 'ⶨ'
    EthiopicSyllableCca,
    /// \u{2da9}: 'ⶩ'
    EthiopicSyllableCcu,
    /// \u{2daa}: 'ⶪ'
    EthiopicSyllableCci,
    /// \u{2dab}: 'ⶫ'
    EthiopicSyllableCcaa,
    /// \u{2dac}: 'ⶬ'
    EthiopicSyllableCcee,
    /// \u{2dad}: 'ⶭ'
    EthiopicSyllableCce,
    /// \u{2dae}: 'ⶮ'
    EthiopicSyllableCco,
    /// \u{2db0}: 'ⶰ'
    EthiopicSyllableZza,
    /// \u{2db1}: 'ⶱ'
    EthiopicSyllableZzu,
    /// \u{2db2}: 'ⶲ'
    EthiopicSyllableZzi,
    /// \u{2db3}: 'ⶳ'
    EthiopicSyllableZzaa,
    /// \u{2db4}: 'ⶴ'
    EthiopicSyllableZzee,
    /// \u{2db5}: 'ⶵ'
    EthiopicSyllableZze,
    /// \u{2db6}: 'ⶶ'
    EthiopicSyllableZzo,
    /// \u{2db8}: 'ⶸ'
    EthiopicSyllableCcha,
    /// \u{2db9}: 'ⶹ'
    EthiopicSyllableCchu,
    /// \u{2dba}: 'ⶺ'
    EthiopicSyllableCchi,
    /// \u{2dbb}: 'ⶻ'
    EthiopicSyllableCchaa,
    /// \u{2dbc}: 'ⶼ'
    EthiopicSyllableCchee,
    /// \u{2dbd}: 'ⶽ'
    EthiopicSyllableCche,
    /// \u{2dbe}: 'ⶾ'
    EthiopicSyllableCcho,
    /// \u{2dc0}: 'ⷀ'
    EthiopicSyllableQya,
    /// \u{2dc1}: 'ⷁ'
    EthiopicSyllableQyu,
    /// \u{2dc2}: 'ⷂ'
    EthiopicSyllableQyi,
    /// \u{2dc3}: 'ⷃ'
    EthiopicSyllableQyaa,
    /// \u{2dc4}: 'ⷄ'
    EthiopicSyllableQyee,
    /// \u{2dc5}: 'ⷅ'
    EthiopicSyllableQye,
    /// \u{2dc6}: 'ⷆ'
    EthiopicSyllableQyo,
    /// \u{2dc8}: 'ⷈ'
    EthiopicSyllableKya,
    /// \u{2dc9}: 'ⷉ'
    EthiopicSyllableKyu,
    /// \u{2dca}: 'ⷊ'
    EthiopicSyllableKyi,
    /// \u{2dcb}: 'ⷋ'
    EthiopicSyllableKyaa,
    /// \u{2dcc}: 'ⷌ'
    EthiopicSyllableKyee,
    /// \u{2dcd}: 'ⷍ'
    EthiopicSyllableKye,
    /// \u{2dce}: 'ⷎ'
    EthiopicSyllableKyo,
    /// \u{2dd0}: 'ⷐ'
    EthiopicSyllableXya,
    /// \u{2dd1}: 'ⷑ'
    EthiopicSyllableXyu,
    /// \u{2dd2}: 'ⷒ'
    EthiopicSyllableXyi,
    /// \u{2dd3}: 'ⷓ'
    EthiopicSyllableXyaa,
    /// \u{2dd4}: 'ⷔ'
    EthiopicSyllableXyee,
    /// \u{2dd5}: 'ⷕ'
    EthiopicSyllableXye,
    /// \u{2dd6}: 'ⷖ'
    EthiopicSyllableXyo,
    /// \u{2dd8}: 'ⷘ'
    EthiopicSyllableGya,
    /// \u{2dd9}: 'ⷙ'
    EthiopicSyllableGyu,
    /// \u{2dda}: 'ⷚ'
    EthiopicSyllableGyi,
    /// \u{2ddb}: 'ⷛ'
    EthiopicSyllableGyaa,
    /// \u{2ddc}: 'ⷜ'
    EthiopicSyllableGyee,
    /// \u{2ddd}: 'ⷝ'
    EthiopicSyllableGye,
    /// \u{2dde}: 'ⷞ'
    EthiopicSyllableGyo,
}

impl Into<char> for EthiopicExtended {
    fn into(self) -> char {
        match self {
            EthiopicExtended::EthiopicSyllableLoa => 'ⶀ',
            EthiopicExtended::EthiopicSyllableMoa => 'ⶁ',
            EthiopicExtended::EthiopicSyllableRoa => 'ⶂ',
            EthiopicExtended::EthiopicSyllableSoa => 'ⶃ',
            EthiopicExtended::EthiopicSyllableShoa => 'ⶄ',
            EthiopicExtended::EthiopicSyllableBoa => 'ⶅ',
            EthiopicExtended::EthiopicSyllableToa => 'ⶆ',
            EthiopicExtended::EthiopicSyllableCoa => 'ⶇ',
            EthiopicExtended::EthiopicSyllableNoa => 'ⶈ',
            EthiopicExtended::EthiopicSyllableNyoa => 'ⶉ',
            EthiopicExtended::EthiopicSyllableGlottalOa => 'ⶊ',
            EthiopicExtended::EthiopicSyllableZoa => 'ⶋ',
            EthiopicExtended::EthiopicSyllableDoa => 'ⶌ',
            EthiopicExtended::EthiopicSyllableDdoa => 'ⶍ',
            EthiopicExtended::EthiopicSyllableJoa => 'ⶎ',
            EthiopicExtended::EthiopicSyllableThoa => 'ⶏ',
            EthiopicExtended::EthiopicSyllableChoa => 'ⶐ',
            EthiopicExtended::EthiopicSyllablePhoa => 'ⶑ',
            EthiopicExtended::EthiopicSyllablePoa => 'ⶒ',
            EthiopicExtended::EthiopicSyllableGgwa => 'ⶓ',
            EthiopicExtended::EthiopicSyllableGgwi => 'ⶔ',
            EthiopicExtended::EthiopicSyllableGgwee => 'ⶕ',
            EthiopicExtended::EthiopicSyllableGgwe => 'ⶖ',
            EthiopicExtended::EthiopicSyllableSsa => 'ⶠ',
            EthiopicExtended::EthiopicSyllableSsu => 'ⶡ',
            EthiopicExtended::EthiopicSyllableSsi => 'ⶢ',
            EthiopicExtended::EthiopicSyllableSsaa => 'ⶣ',
            EthiopicExtended::EthiopicSyllableSsee => 'ⶤ',
            EthiopicExtended::EthiopicSyllableSse => 'ⶥ',
            EthiopicExtended::EthiopicSyllableSso => 'ⶦ',
            EthiopicExtended::EthiopicSyllableCca => 'ⶨ',
            EthiopicExtended::EthiopicSyllableCcu => 'ⶩ',
            EthiopicExtended::EthiopicSyllableCci => 'ⶪ',
            EthiopicExtended::EthiopicSyllableCcaa => 'ⶫ',
            EthiopicExtended::EthiopicSyllableCcee => 'ⶬ',
            EthiopicExtended::EthiopicSyllableCce => 'ⶭ',
            EthiopicExtended::EthiopicSyllableCco => 'ⶮ',
            EthiopicExtended::EthiopicSyllableZza => 'ⶰ',
            EthiopicExtended::EthiopicSyllableZzu => 'ⶱ',
            EthiopicExtended::EthiopicSyllableZzi => 'ⶲ',
            EthiopicExtended::EthiopicSyllableZzaa => 'ⶳ',
            EthiopicExtended::EthiopicSyllableZzee => 'ⶴ',
            EthiopicExtended::EthiopicSyllableZze => 'ⶵ',
            EthiopicExtended::EthiopicSyllableZzo => 'ⶶ',
            EthiopicExtended::EthiopicSyllableCcha => 'ⶸ',
            EthiopicExtended::EthiopicSyllableCchu => 'ⶹ',
            EthiopicExtended::EthiopicSyllableCchi => 'ⶺ',
            EthiopicExtended::EthiopicSyllableCchaa => 'ⶻ',
            EthiopicExtended::EthiopicSyllableCchee => 'ⶼ',
            EthiopicExtended::EthiopicSyllableCche => 'ⶽ',
            EthiopicExtended::EthiopicSyllableCcho => 'ⶾ',
            EthiopicExtended::EthiopicSyllableQya => 'ⷀ',
            EthiopicExtended::EthiopicSyllableQyu => 'ⷁ',
            EthiopicExtended::EthiopicSyllableQyi => 'ⷂ',
            EthiopicExtended::EthiopicSyllableQyaa => 'ⷃ',
            EthiopicExtended::EthiopicSyllableQyee => 'ⷄ',
            EthiopicExtended::EthiopicSyllableQye => 'ⷅ',
            EthiopicExtended::EthiopicSyllableQyo => 'ⷆ',
            EthiopicExtended::EthiopicSyllableKya => 'ⷈ',
            EthiopicExtended::EthiopicSyllableKyu => 'ⷉ',
            EthiopicExtended::EthiopicSyllableKyi => 'ⷊ',
            EthiopicExtended::EthiopicSyllableKyaa => 'ⷋ',
            EthiopicExtended::EthiopicSyllableKyee => 'ⷌ',
            EthiopicExtended::EthiopicSyllableKye => 'ⷍ',
            EthiopicExtended::EthiopicSyllableKyo => 'ⷎ',
            EthiopicExtended::EthiopicSyllableXya => 'ⷐ',
            EthiopicExtended::EthiopicSyllableXyu => 'ⷑ',
            EthiopicExtended::EthiopicSyllableXyi => 'ⷒ',
            EthiopicExtended::EthiopicSyllableXyaa => 'ⷓ',
            EthiopicExtended::EthiopicSyllableXyee => 'ⷔ',
            EthiopicExtended::EthiopicSyllableXye => 'ⷕ',
            EthiopicExtended::EthiopicSyllableXyo => 'ⷖ',
            EthiopicExtended::EthiopicSyllableGya => 'ⷘ',
            EthiopicExtended::EthiopicSyllableGyu => 'ⷙ',
            EthiopicExtended::EthiopicSyllableGyi => 'ⷚ',
            EthiopicExtended::EthiopicSyllableGyaa => 'ⷛ',
            EthiopicExtended::EthiopicSyllableGyee => 'ⷜ',
            EthiopicExtended::EthiopicSyllableGye => 'ⷝ',
            EthiopicExtended::EthiopicSyllableGyo => 'ⷞ',
        }
    }
}

impl std::convert::TryFrom<char> for EthiopicExtended {
    type Error = ();
    fn try_from(c: char) -> Result<Self, Self::Error> {
        match c {
            'ⶀ' => Ok(EthiopicExtended::EthiopicSyllableLoa),
            'ⶁ' => Ok(EthiopicExtended::EthiopicSyllableMoa),
            'ⶂ' => Ok(EthiopicExtended::EthiopicSyllableRoa),
            'ⶃ' => Ok(EthiopicExtended::EthiopicSyllableSoa),
            'ⶄ' => Ok(EthiopicExtended::EthiopicSyllableShoa),
            'ⶅ' => Ok(EthiopicExtended::EthiopicSyllableBoa),
            'ⶆ' => Ok(EthiopicExtended::EthiopicSyllableToa),
            'ⶇ' => Ok(EthiopicExtended::EthiopicSyllableCoa),
            'ⶈ' => Ok(EthiopicExtended::EthiopicSyllableNoa),
            'ⶉ' => Ok(EthiopicExtended::EthiopicSyllableNyoa),
            'ⶊ' => Ok(EthiopicExtended::EthiopicSyllableGlottalOa),
            'ⶋ' => Ok(EthiopicExtended::EthiopicSyllableZoa),
            'ⶌ' => Ok(EthiopicExtended::EthiopicSyllableDoa),
            'ⶍ' => Ok(EthiopicExtended::EthiopicSyllableDdoa),
            'ⶎ' => Ok(EthiopicExtended::EthiopicSyllableJoa),
            'ⶏ' => Ok(EthiopicExtended::EthiopicSyllableThoa),
            'ⶐ' => Ok(EthiopicExtended::EthiopicSyllableChoa),
            'ⶑ' => Ok(EthiopicExtended::EthiopicSyllablePhoa),
            'ⶒ' => Ok(EthiopicExtended::EthiopicSyllablePoa),
            'ⶓ' => Ok(EthiopicExtended::EthiopicSyllableGgwa),
            'ⶔ' => Ok(EthiopicExtended::EthiopicSyllableGgwi),
            'ⶕ' => Ok(EthiopicExtended::EthiopicSyllableGgwee),
            'ⶖ' => Ok(EthiopicExtended::EthiopicSyllableGgwe),
            'ⶠ' => Ok(EthiopicExtended::EthiopicSyllableSsa),
            'ⶡ' => Ok(EthiopicExtended::EthiopicSyllableSsu),
            'ⶢ' => Ok(EthiopicExtended::EthiopicSyllableSsi),
            'ⶣ' => Ok(EthiopicExtended::EthiopicSyllableSsaa),
            'ⶤ' => Ok(EthiopicExtended::EthiopicSyllableSsee),
            'ⶥ' => Ok(EthiopicExtended::EthiopicSyllableSse),
            'ⶦ' => Ok(EthiopicExtended::EthiopicSyllableSso),
            'ⶨ' => Ok(EthiopicExtended::EthiopicSyllableCca),
            'ⶩ' => Ok(EthiopicExtended::EthiopicSyllableCcu),
            'ⶪ' => Ok(EthiopicExtended::EthiopicSyllableCci),
            'ⶫ' => Ok(EthiopicExtended::EthiopicSyllableCcaa),
            'ⶬ' => Ok(EthiopicExtended::EthiopicSyllableCcee),
            'ⶭ' => Ok(EthiopicExtended::EthiopicSyllableCce),
            'ⶮ' => Ok(EthiopicExtended::EthiopicSyllableCco),
            'ⶰ' => Ok(EthiopicExtended::EthiopicSyllableZza),
            'ⶱ' => Ok(EthiopicExtended::EthiopicSyllableZzu),
            'ⶲ' => Ok(EthiopicExtended::EthiopicSyllableZzi),
            'ⶳ' => Ok(EthiopicExtended::EthiopicSyllableZzaa),
            'ⶴ' => Ok(EthiopicExtended::EthiopicSyllableZzee),
            'ⶵ' => Ok(EthiopicExtended::EthiopicSyllableZze),
            'ⶶ' => Ok(EthiopicExtended::EthiopicSyllableZzo),
            'ⶸ' => Ok(EthiopicExtended::EthiopicSyllableCcha),
            'ⶹ' => Ok(EthiopicExtended::EthiopicSyllableCchu),
            'ⶺ' => Ok(EthiopicExtended::EthiopicSyllableCchi),
            'ⶻ' => Ok(EthiopicExtended::EthiopicSyllableCchaa),
            'ⶼ' => Ok(EthiopicExtended::EthiopicSyllableCchee),
            'ⶽ' => Ok(EthiopicExtended::EthiopicSyllableCche),
            'ⶾ' => Ok(EthiopicExtended::EthiopicSyllableCcho),
            'ⷀ' => Ok(EthiopicExtended::EthiopicSyllableQya),
            'ⷁ' => Ok(EthiopicExtended::EthiopicSyllableQyu),
            'ⷂ' => Ok(EthiopicExtended::EthiopicSyllableQyi),
            'ⷃ' => Ok(EthiopicExtended::EthiopicSyllableQyaa),
            'ⷄ' => Ok(EthiopicExtended::EthiopicSyllableQyee),
            'ⷅ' => Ok(EthiopicExtended::EthiopicSyllableQye),
            'ⷆ' => Ok(EthiopicExtended::EthiopicSyllableQyo),
            'ⷈ' => Ok(EthiopicExtended::EthiopicSyllableKya),
            'ⷉ' => Ok(EthiopicExtended::EthiopicSyllableKyu),
            'ⷊ' => Ok(EthiopicExtended::EthiopicSyllableKyi),
            'ⷋ' => Ok(EthiopicExtended::EthiopicSyllableKyaa),
            'ⷌ' => Ok(EthiopicExtended::EthiopicSyllableKyee),
            'ⷍ' => Ok(EthiopicExtended::EthiopicSyllableKye),
            'ⷎ' => Ok(EthiopicExtended::EthiopicSyllableKyo),
            'ⷐ' => Ok(EthiopicExtended::EthiopicSyllableXya),
            'ⷑ' => Ok(EthiopicExtended::EthiopicSyllableXyu),
            'ⷒ' => Ok(EthiopicExtended::EthiopicSyllableXyi),
            'ⷓ' => Ok(EthiopicExtended::EthiopicSyllableXyaa),
            'ⷔ' => Ok(EthiopicExtended::EthiopicSyllableXyee),
            'ⷕ' => Ok(EthiopicExtended::EthiopicSyllableXye),
            'ⷖ' => Ok(EthiopicExtended::EthiopicSyllableXyo),
            'ⷘ' => Ok(EthiopicExtended::EthiopicSyllableGya),
            'ⷙ' => Ok(EthiopicExtended::EthiopicSyllableGyu),
            'ⷚ' => Ok(EthiopicExtended::EthiopicSyllableGyi),
            'ⷛ' => Ok(EthiopicExtended::EthiopicSyllableGyaa),
            'ⷜ' => Ok(EthiopicExtended::EthiopicSyllableGyee),
            'ⷝ' => Ok(EthiopicExtended::EthiopicSyllableGye),
            'ⷞ' => Ok(EthiopicExtended::EthiopicSyllableGyo),
            _ => Err(()),
        }
    }
}

impl Into<u32> for EthiopicExtended {
    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 EthiopicExtended {
    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 EthiopicExtended {
    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 EthiopicExtended {
    /// The character with the lowest index in this unicode block
    pub fn new() -> Self {
        EthiopicExtended::EthiopicSyllableLoa
    }

    /// The character's name, in sentence case
    pub fn name(&self) -> String {
        let s = std::format!("EthiopicExtended{:#?}", self);
        string_morph::to_sentence_case(&s)
    }
}