control_code/csi/
combination.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 Combination {
19	Next,
20	Start,
21	End,
22}
23
24impl Combination {
25	#[inline]
26	pub fn parse<'a>(value: u32) -> Result<Self, nom::ErrorKind> {
27		match value {
28			0 => Ok(Combination::Next),
29			1 => Ok(Combination::Start),
30			2 => Ok(Combination::End),
31			_ => Err(nom::ErrorKind::Custom(9005)),
32		}
33	}
34}
35
36impl Into<u32> for Combination {
37	#[inline]
38	fn into(self) -> u32 {
39		match self {
40			Combination::Next  => 0,
41			Combination::Start => 1,
42			Combination::End   => 2,
43		}
44	}
45}