hd44780_controller/charset/
common.rs1pub trait Charset {
2 fn char_to_code(&self, c: char) -> Option<u8>;
3}
4
5pub trait InfallibleCharset {
6 fn char_to_code(&self, c: char) -> u8;
7}
8
9pub struct BlankFallback<C: Charset>(pub C);
10pub struct QuestionFallback<C: Charset>(pub C);
11
12impl<C: Charset> InfallibleCharset for BlankFallback<C> {
13 fn char_to_code(&self, c: char) -> u8 {
14 self.0.char_to_code(c).unwrap_or(b' ')
15 }
16}
17
18impl<C: Charset> InfallibleCharset for QuestionFallback<C> {
19 fn char_to_code(&self, c: char) -> u8 {
20 self.0.char_to_code(c).unwrap_or(b'?')
21 }
22}