control_code/csi/
tabulation.rs1use nom;
16
17#[derive(Eq, PartialEq, Copy, Clone, Debug)]
18pub enum Tabulation {
19 Character,
20 Line,
21 Characters,
22 AllCharacters,
23 AllLines,
24 All,
25}
26
27impl Tabulation {
28 #[inline]
29 pub fn parse<'a>(value: u32) -> Result<Self, nom::ErrorKind> {
30 match value {
31 0 => Ok(Tabulation::Character),
32 1 => Ok(Tabulation::Line),
33 2 => Ok(Tabulation::Characters),
34 3 => Ok(Tabulation::AllCharacters),
35 4 => Ok(Tabulation::AllLines),
36 5 => Ok(Tabulation::All),
37 _ => Err(nom::ErrorKind::Custom(9003)),
38 }
39 }
40}
41
42impl Into<u32> for Tabulation {
43 #[inline]
44 fn into(self) -> u32 {
45 match self {
46 Tabulation::Character => 0,
47 Tabulation::Line => 1,
48 Tabulation::Characters => 2,
49 Tabulation::AllCharacters => 3,
50 Tabulation::AllLines => 4,
51 Tabulation::All => 5,
52 }
53 }
54}