1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#[repr(u32)]
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum NcPixelImpl {
None = c_api::NCPIXEL_NONE,
Sixel = c_api::NCPIXEL_SIXEL,
LinuxFb = c_api::NCPIXEL_LINUXFB,
Iterm2 = c_api::NCPIXEL_ITERM2,
KittyStatic = c_api::NCPIXEL_KITTY_STATIC,
KittyAnimated = c_api::NCPIXEL_KITTY_ANIMATED,
KittySelfRef = c_api::NCPIXEL_KITTY_SELFREF,
}
mod std_impls {
use super::{c_api::*, NcPixelImpl};
use std::fmt;
impl Default for NcPixelImpl {
fn default() -> Self {
Self::None
}
}
impl fmt::Display for NcPixelImpl {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use NcPixelImpl::*;
write!(
f,
"{}",
match self {
NcPixelImpl::None => "None",
Sixel => "Sixel",
LinuxFb => "LinuxFb",
Iterm2 => "Iterm2",
KittyStatic => "KittyStatic",
KittyAnimated => "KittyAnimated",
KittySelfRef => "KittySelfRef",
}
)
}
}
impl From<NcPixelImpl_u32> for NcPixelImpl {
fn from(alpha: NcPixelImpl_u32) -> Self {
use NcPixelImpl::*;
match alpha {
NCPIXEL_NONE => NcPixelImpl::None,
NCPIXEL_SIXEL => Sixel,
NCPIXEL_LINUXFB => LinuxFb,
NCPIXEL_ITERM2 => Iterm2,
NCPIXEL_KITTY_STATIC => KittyStatic,
NCPIXEL_KITTY_ANIMATED => KittyAnimated,
NCPIXEL_KITTY_SELFREF => KittySelfRef,
_ => Self::default(),
}
}
}
impl From<NcPixelImpl> for NcPixelImpl_u32 {
fn from(alpha: NcPixelImpl) -> Self {
use NcPixelImpl::*;
match alpha {
NcPixelImpl::None => NCPIXEL_NONE,
Sixel => NCPIXEL_SIXEL,
LinuxFb => NCPIXEL_LINUXFB,
Iterm2 => NCPIXEL_ITERM2,
KittyStatic => NCPIXEL_KITTY_STATIC,
KittyAnimated => NCPIXEL_KITTY_ANIMATED,
KittySelfRef => NCPIXEL_KITTY_SELFREF,
}
}
}
}
pub(crate) mod c_api {
use crate::c_api::ffi;
pub type NcPixelImpl_u32 = ffi::ncpixelimpl_e;
pub const NCPIXEL_NONE: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_NONE;
pub const NCPIXEL_SIXEL: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_SIXEL;
pub const NCPIXEL_LINUXFB: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_LINUXFB;
pub const NCPIXEL_ITERM2: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_ITERM2;
pub const NCPIXEL_KITTY_STATIC: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_KITTY_STATIC;
pub const NCPIXEL_KITTY_ANIMATED: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_KITTY_ANIMATED;
pub const NCPIXEL_KITTY_SELFREF: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_KITTY_SELFREF;
}