control_code/csi/
report.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 Report {
19	CursorPosition,
20	Private(u32),
21}
22
23impl Report {
24	#[inline]
25	pub fn parse<'a>(value: u32) -> Result<Self, nom::ErrorKind> {
26		match value {
27			6 => Ok(Report::CursorPosition),
28			n => Ok(Report::Private(n)),
29		}
30	}
31}
32
33impl Into<u32> for Report {
34	#[inline]
35	fn into(self) -> u32 {
36		match self {
37			Report::CursorPosition => 6,
38			Report::Private(n)     => n,
39		}
40	}
41}