control_code/csi/erase.rs
1// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2// Version 2, December 2004
3//
4// Copyleft (ↄ) meh. <meh@schizofreni.co> | http://meh.schizofreni.co
5//
6// Everyone is permitted to copy and distribute verbatim or modified
7// copies of this license document, and changing it is allowed as long
8// as the name is changed.
9//
10// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11// TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12//
13// 0. You just DO WHAT THE FUCK YOU WANT TO.
14
15use nom;
16
17#[derive(Eq, PartialEq, Copy, Clone, Debug)]
18pub enum Erase {
19 ToEnd,
20 ToStart,
21 All,
22}
23
24impl Erase {
25 #[inline]
26 pub fn parse<'a>(value: u32) -> Result<Self, nom::ErrorKind> {
27 match value {
28 0 => Ok(Erase::ToEnd),
29 1 => Ok(Erase::ToStart),
30 2 => Ok(Erase::All),
31 _ => Err(nom::ErrorKind::Custom(9002)),
32 }
33 }
34}
35
36impl Into<u32> for Erase {
37 #[inline]
38 fn into(self) -> u32 {
39 match self {
40 Erase::ToEnd => 0,
41 Erase::ToStart => 1,
42 Erase::All => 2,
43 }
44 }
45}