1#[derive(#[automatically_derived]impl ::core::fmt::Debug for Action {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_c_like_enum_write_str(f,
"InvalidSequence EmitByte SetByte1 SetByte2 SetByte2Top SetByte3 SetByte3Top SetByte4",
match self {
Action::InvalidSequence => 0usize,
Action::EmitByte => 16usize,
Action::SetByte1 => 25usize,
Action::SetByte2 => 34usize,
Action::SetByte2Top => 43usize,
Action::SetByte3 => 55usize,
Action::SetByte3Top => 64usize,
Action::SetByte4 => 76usize,
})
}
}Debug, #[automatically_derived]impl ::core::marker::Copy for Action { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for Action {
}
#[automatically_derived]impl ::core::clone::Clone for Action {
#[inline]
fn clone(&self) -> Self { *self }
}Clone)]
5pub enum Action {
6 InvalidSequence = 0,
8 EmitByte = 1,
10 SetByte1 = 2,
12 SetByte2 = 3,
14 SetByte2Top = 4,
16 SetByte3 = 5,
18 SetByte3Top = 6,
20 SetByte4 = 7,
22}
23
24#[allow(non_camel_case_types)]
29#[derive(#[automatically_derived]#[allow(non_camel_case_types)]
impl ::core::fmt::Debug for State {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_c_like_enum_write_str(f,
"Ground Tail3 Tail2 Tail1 U3_2_e0 U3_2_ed Utf8_4_3_f0 Utf8_4_3_f4",
match self {
State::Ground => 0usize,
State::Tail3 => 7usize,
State::Tail2 => 13usize,
State::Tail1 => 19usize,
State::U3_2_e0 => 25usize,
State::U3_2_ed => 33usize,
State::Utf8_4_3_f0 => 41usize,
State::Utf8_4_3_f4 => 53usize,
})
}
}Debug, #[automatically_derived]#[allow(non_camel_case_types)]
impl ::core::default::Default for State {
#[inline]
fn default() -> Self { Self::Ground }
}Default, #[automatically_derived]#[allow(non_camel_case_types)]
impl ::core::marker::Copy for State { }Copy, #[automatically_derived]#[doc(hidden)]#[allow(non_camel_case_types)]
unsafe impl ::core::clone::TrivialClone for State { }
#[automatically_derived]#[allow(non_camel_case_types)]
impl ::core::clone::Clone for State {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]#[allow(non_camel_case_types)]
impl ::core::marker::StructuralPartialEq for State { }
#[automatically_derived]#[allow(non_camel_case_types)]
impl ::core::cmp::PartialEq for State {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]#[allow(non_camel_case_types)]
impl ::core::cmp::Eq for State { }Eq)]
30pub enum State {
31 #[default]
33 Ground = 0,
34 Tail3 = 1,
36 Tail2 = 2,
38 Tail1 = 3,
40 U3_2_e0 = 4,
42 U3_2_ed = 5,
44 Utf8_4_3_f0 = 6,
46 Utf8_4_3_f4 = 7,
48}
49
50impl State {
51 #[inline]
56 pub fn advance(self, byte: u8) -> (State, Action) {
57 match self {
58 State::Ground => match byte {
59 0x00..=0x7f => (State::Ground, Action::EmitByte),
60 0xc2..=0xdf => (State::Tail1, Action::SetByte2Top),
61 0xe0 => (State::U3_2_e0, Action::SetByte3Top),
62 0xe1..=0xec => (State::Tail2, Action::SetByte3Top),
63 0xed => (State::U3_2_ed, Action::SetByte3Top),
64 0xee..=0xef => (State::Tail2, Action::SetByte3Top),
65 0xf0 => (State::Utf8_4_3_f0, Action::SetByte4),
66 0xf1..=0xf3 => (State::Tail3, Action::SetByte4),
67 0xf4 => (State::Utf8_4_3_f4, Action::SetByte4),
68 _ => (State::Ground, Action::InvalidSequence),
69 },
70 State::U3_2_e0 => match byte {
71 0xa0..=0xbf => (State::Tail1, Action::SetByte2),
72 _ => (State::Ground, Action::InvalidSequence),
73 },
74 State::U3_2_ed => match byte {
75 0x80..=0x9f => (State::Tail1, Action::SetByte2),
76 _ => (State::Ground, Action::InvalidSequence),
77 },
78 State::Utf8_4_3_f0 => match byte {
79 0x90..=0xbf => (State::Tail2, Action::SetByte3),
80 _ => (State::Ground, Action::InvalidSequence),
81 },
82 State::Utf8_4_3_f4 => match byte {
83 0x80..=0x8f => (State::Tail2, Action::SetByte3),
84 _ => (State::Ground, Action::InvalidSequence),
85 },
86 State::Tail3 => match byte {
87 0x80..=0xbf => (State::Tail2, Action::SetByte3),
88 _ => (State::Ground, Action::InvalidSequence),
89 },
90 State::Tail2 => match byte {
91 0x80..=0xbf => (State::Tail1, Action::SetByte2),
92 _ => (State::Ground, Action::InvalidSequence),
93 },
94 State::Tail1 => match byte {
95 0x80..=0xbf => (State::Ground, Action::SetByte1),
96 _ => (State::Ground, Action::InvalidSequence),
97 },
98 }
99 }
100}