libnotcurses_sys/input/
input_type.rs1#[repr(u32)]
7#[derive(Clone, Copy, PartialEq, Eq)]
8pub enum NcInputType {
9 Unknown,
11
12 Press,
14
15 Repeat,
17
18 Release,
20}
21
22mod core_impls {
23 use super::{c_api::*, NcInputType};
24 use core::fmt;
25
26 impl Default for NcInputType {
27 fn default() -> Self {
28 Self::Unknown
29 }
30 }
31
32 impl fmt::Display for NcInputType {
33 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
34 use NcInputType::*;
35 write!(
36 f,
37 "{}",
38 match self {
39 Unknown => "Unknown",
40 Press => "Press",
41 Repeat => "Repeat",
42 Release => "Release",
43 }
44 )
45 }
46 }
47
48 impl fmt::Debug for NcInputType {
49 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
50 write!(f, "NcInputType::{}", self)
51 }
52 }
53
54 impl From<NcInputType> for u32 {
55 fn from(it: NcInputType) -> Self {
56 use NcInputType::*;
57 match it {
58 Unknown => NCTYPE_UNKNOWN,
59 Press => NCTYPE_PRESS,
60 Repeat => NCTYPE_REPEAT,
61 Release => NCTYPE_RELEASE,
62 }
63 }
64 }
65
66 impl From<u32> for NcInputType {
67 fn from(value: u32) -> Self {
68 use NcInputType::*;
69 match value {
70 NCTYPE_UNKNOWN => Unknown,
71 NCTYPE_PRESS => Press,
72 NCTYPE_REPEAT => Repeat,
73 NCTYPE_RELEASE => Release,
74 _ => Unknown,
75 }
76 }
77 }
78}
79
80pub(crate) mod c_api {
81 use crate::c_api::ffi;
82
83 pub type NcInputType_u32 = u32;
93
94 pub const NCTYPE_UNKNOWN: u32 = ffi::ncintype_e_NCTYPE_UNKNOWN;
96
97 pub const NCTYPE_PRESS: u32 = ffi::ncintype_e_NCTYPE_PRESS;
99
100 pub const NCTYPE_REPEAT: u32 = ffi::ncintype_e_NCTYPE_REPEAT;
102
103 pub const NCTYPE_RELEASE: u32 = ffi::ncintype_e_NCTYPE_RELEASE;
105}