libnotcurses_sys/
align.rs1#[repr(u32)]
13#[derive(Debug, Clone, Copy, PartialEq, Eq)]
14pub enum NcAlign {
15 Unaligned = c_api::NCALIGN_UNALIGNED,
17 Left = c_api::NCALIGN_LEFT,
19 Center = c_api::NCALIGN_CENTER,
21 Right = c_api::NCALIGN_RIGHT,
23}
24
25mod core_impls {
26 use super::{c_api, NcAlign};
27 use core::fmt;
28
29 impl Default for NcAlign {
30 fn default() -> Self {
31 Self::Left
32 }
33 }
34
35 impl NcAlign {
37 pub const Top: NcAlign = NcAlign::Left;
39 pub const Bottom: NcAlign = NcAlign::Right;
41 }
42
43 impl fmt::Display for NcAlign {
44 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
45 use NcAlign::*;
46 write!(
47 f,
48 "{}",
49 match self {
50 Left => "Left",
51 Center => "Center",
52 Right => "Right",
53 Unaligned => "Unaligned",
54 }
55 )
56 }
57 }
58
59 impl From<c_api::NcAlign_u32> for NcAlign {
60 fn from(align: c_api::NcAlign_u32) -> Self {
61 use {c_api::*, NcAlign::*};
62 match align {
63 NCALIGN_LEFT => Left,
64 NCALIGN_CENTER => Center,
65 NCALIGN_RIGHT => Right,
66 NCALIGN_UNALIGNED => Unaligned,
67 _ => Unaligned, }
69 }
70 }
71
72 impl From<NcAlign> for c_api::NcAlign_u32 {
73 fn from(align: NcAlign) -> Self {
74 use {c_api::*, NcAlign::*};
75 match align {
76 Left => NCALIGN_LEFT,
77 Center => NCALIGN_CENTER,
78 Right => NCALIGN_RIGHT,
79 Unaligned => NCALIGN_UNALIGNED,
80 }
81 }
82 }
83
84 impl From<i32> for NcAlign {
85 fn from(align: i32) -> Self {
86 use {c_api::*, NcAlign::*};
87
88 const NCALIGN_LEFT_i32: i32 = NCALIGN_LEFT as i32;
89 const NCALIGN_CENTER_i32: i32 = NCALIGN_CENTER as i32;
90 const NCALIGN_RIGHT_i32: i32 = NCALIGN_RIGHT as i32;
91 const NCALIGN_UNALIGNED_i32: i32 = NCALIGN_UNALIGNED as i32;
92
93 match align {
94 NCALIGN_LEFT_i32 => Left,
95 NCALIGN_CENTER_i32 => Center,
96 NCALIGN_RIGHT_i32 => Right,
97 NCALIGN_UNALIGNED_i32 => Unaligned,
98 _ => Unaligned,
99 }
100 }
101 }
102
103 impl From<NcAlign> for i32 {
104 fn from(align: NcAlign) -> Self {
105 use {c_api::*, NcAlign::*};
106 match align {
107 Left => NCALIGN_LEFT as i32,
108 Center => NCALIGN_CENTER as i32,
109 Right => NCALIGN_RIGHT as i32,
110 Unaligned => NCALIGN_UNALIGNED as i32,
111 }
112 }
113 }
114}
115
116pub(crate) mod c_api {
117 use crate::c_api::ffi;
118
119 pub type NcAlign_u32 = ffi::ncalign_e;
132
133 pub const NCALIGN_LEFT: NcAlign_u32 = ffi::ncalign_e_NCALIGN_LEFT;
135
136 pub const NCALIGN_RIGHT: NcAlign_u32 = ffi::ncalign_e_NCALIGN_RIGHT;
138
139 pub const NCALIGN_TOP: NcAlign_u32 = NCALIGN_LEFT;
141
142 pub const NCALIGN_BOTTOM: NcAlign_u32 = NCALIGN_RIGHT;
144
145 pub const NCALIGN_CENTER: NcAlign_u32 = ffi::ncalign_e_NCALIGN_CENTER;
147
148 pub const NCALIGN_UNALIGNED: NcAlign_u32 = ffi::ncalign_e_NCALIGN_UNALIGNED;
150}