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
use super::DataReg;
use crate::typelevel::Sealed;
use num_traits::{AsPrimitive, PrimInt};
pub trait CharSize: Sealed {
type Word: 'static + PrimInt + AsPrimitive<DataReg>;
}
pub trait FixedCharSize: CharSize {
const SIZE: CharSizeEnum;
}
pub type Word<C> = <C as CharSize>::Word;
pub enum FiveBit {}
pub enum SixBit {}
pub enum SevenBit {}
pub enum EightBit {}
pub enum NineBit {}
pub enum DynCharSize {}
#[repr(u8)]
pub enum CharSizeEnum {
FiveBit = 0x5,
SixBit = 0x6,
SevenBit = 0x7,
EightBit = 0x0,
NineBit = 0x1,
}
impl Sealed for FiveBit {}
impl CharSize for FiveBit {
type Word = u8;
}
impl FixedCharSize for FiveBit {
const SIZE: CharSizeEnum = CharSizeEnum::FiveBit;
}
impl Sealed for SixBit {}
impl CharSize for SixBit {
type Word = u8;
}
impl FixedCharSize for SixBit {
const SIZE: CharSizeEnum = CharSizeEnum::SixBit;
}
impl Sealed for SevenBit {}
impl CharSize for SevenBit {
type Word = u8;
}
impl FixedCharSize for SevenBit {
const SIZE: CharSizeEnum = CharSizeEnum::SevenBit;
}
impl Sealed for EightBit {}
impl CharSize for EightBit {
type Word = u8;
}
impl FixedCharSize for EightBit {
const SIZE: CharSizeEnum = CharSizeEnum::EightBit;
}
impl Sealed for NineBit {}
impl CharSize for NineBit {
type Word = u16;
}
impl FixedCharSize for NineBit {
const SIZE: CharSizeEnum = CharSizeEnum::NineBit;
}
impl Sealed for DynCharSize {}
impl CharSize for DynCharSize {
type Word = u16;
}