libnotcurses_sys/pixel/
pixel_impl.rs1#[repr(u32)]
9#[non_exhaustive]
10#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11pub enum NcPixelImpl {
12 None = c_api::NCPIXEL_NONE,
14
15 Sixel = c_api::NCPIXEL_SIXEL,
17
18 LinuxFb = c_api::NCPIXEL_LINUXFB,
20
21 Iterm2 = c_api::NCPIXEL_ITERM2,
23
24 KittyStatic = c_api::NCPIXEL_KITTY_STATIC,
26
27 KittyAnimated = c_api::NCPIXEL_KITTY_ANIMATED,
29
30 KittySelfRef = c_api::NCPIXEL_KITTY_SELFREF,
32}
33
34mod core_impls {
35 use super::{c_api::*, NcPixelImpl};
36 use core::fmt;
37
38 impl Default for NcPixelImpl {
39 fn default() -> Self {
40 Self::None
41 }
42 }
43
44 impl fmt::Display for NcPixelImpl {
45 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
46 use NcPixelImpl::*;
47 write!(
48 f,
49 "{}",
50 match self {
51 NcPixelImpl::None => "None",
52 Sixel => "Sixel",
53 LinuxFb => "LinuxFb",
54 Iterm2 => "Iterm2",
55 KittyStatic => "KittyStatic",
56 KittyAnimated => "KittyAnimated",
57 KittySelfRef => "KittySelfRef",
58 }
59 )
60 }
61 }
62
63 impl From<NcPixelImpl_u32> for NcPixelImpl {
64 fn from(alpha: NcPixelImpl_u32) -> Self {
65 use NcPixelImpl::*;
66 match alpha {
67 NCPIXEL_NONE => NcPixelImpl::None,
68 NCPIXEL_SIXEL => Sixel,
69 NCPIXEL_LINUXFB => LinuxFb,
70 NCPIXEL_ITERM2 => Iterm2,
71 NCPIXEL_KITTY_STATIC => KittyStatic,
72 NCPIXEL_KITTY_ANIMATED => KittyAnimated,
73 NCPIXEL_KITTY_SELFREF => KittySelfRef,
74 _ => Self::default(),
75 }
76 }
77 }
78
79 impl From<NcPixelImpl> for NcPixelImpl_u32 {
80 fn from(alpha: NcPixelImpl) -> Self {
81 use NcPixelImpl::*;
82 match alpha {
83 NcPixelImpl::None => NCPIXEL_NONE,
84 Sixel => NCPIXEL_SIXEL,
85 LinuxFb => NCPIXEL_LINUXFB,
86 Iterm2 => NCPIXEL_ITERM2,
87 KittyStatic => NCPIXEL_KITTY_STATIC,
88 KittyAnimated => NCPIXEL_KITTY_ANIMATED,
89 KittySelfRef => NCPIXEL_KITTY_SELFREF,
90 }
91 }
92 }
93}
94
95pub(crate) mod c_api {
96 use crate::c_api::ffi;
97
98 pub type NcPixelImpl_u32 = ffi::ncpixelimpl_e;
116
117 pub const NCPIXEL_NONE: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_NONE;
119
120 pub const NCPIXEL_SIXEL: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_SIXEL;
122
123 pub const NCPIXEL_LINUXFB: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_LINUXFB;
125
126 pub const NCPIXEL_ITERM2: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_ITERM2;
128
129 pub const NCPIXEL_KITTY_STATIC: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_KITTY_STATIC;
131
132 pub const NCPIXEL_KITTY_ANIMATED: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_KITTY_ANIMATED;
134
135 pub const NCPIXEL_KITTY_SELFREF: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_KITTY_SELFREF;
137}