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
138
139
140
141
142
143
144
145
146
147
148
149
150
#[repr(u32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum NcAlign {
Unaligned = c_api::NCALIGN_UNALIGNED,
Left = c_api::NCALIGN_LEFT,
Center = c_api::NCALIGN_CENTER,
Right = c_api::NCALIGN_RIGHT,
}
mod std_impls {
use super::{c_api, NcAlign};
use std::fmt;
impl Default for NcAlign {
fn default() -> Self {
Self::Left
}
}
impl NcAlign {
pub const Top: NcAlign = NcAlign::Left;
pub const Bottom: NcAlign = NcAlign::Right;
}
impl fmt::Display for NcAlign {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use NcAlign::*;
write!(
f,
"{}",
match self {
Left => "Left",
Center => "Center",
Right => "Right",
Unaligned => "Unaligned",
}
)
}
}
impl From<c_api::NcAlign_u32> for NcAlign {
fn from(align: c_api::NcAlign_u32) -> Self {
use {c_api::*, NcAlign::*};
match align {
NCALIGN_LEFT => Left,
NCALIGN_CENTER => Center,
NCALIGN_RIGHT => Right,
NCALIGN_UNALIGNED => Unaligned,
_ => Unaligned, }
}
}
impl From<NcAlign> for c_api::NcAlign_u32 {
fn from(align: NcAlign) -> Self {
use {c_api::*, NcAlign::*};
match align {
Left => NCALIGN_LEFT,
Center => NCALIGN_CENTER,
Right => NCALIGN_RIGHT,
Unaligned => NCALIGN_UNALIGNED,
}
}
}
impl From<i32> for NcAlign {
fn from(align: i32) -> Self {
use {c_api::*, NcAlign::*};
const NCALIGN_LEFT_i32: i32 = NCALIGN_LEFT as i32;
const NCALIGN_CENTER_i32: i32 = NCALIGN_CENTER as i32;
const NCALIGN_RIGHT_i32: i32 = NCALIGN_RIGHT as i32;
const NCALIGN_UNALIGNED_i32: i32 = NCALIGN_UNALIGNED as i32;
match align {
NCALIGN_LEFT_i32 => Left,
NCALIGN_CENTER_i32 => Center,
NCALIGN_RIGHT_i32 => Right,
NCALIGN_UNALIGNED_i32 => Unaligned,
_ => Unaligned,
}
}
}
impl From<NcAlign> for i32 {
fn from(align: NcAlign) -> Self {
use {c_api::*, NcAlign::*};
match align {
Left => NCALIGN_LEFT as i32,
Center => NCALIGN_CENTER as i32,
Right => NCALIGN_RIGHT as i32,
Unaligned => NCALIGN_UNALIGNED as i32,
}
}
}
}
pub(crate) mod c_api {
use crate::c_api::ffi;
pub type NcAlign_u32 = ffi::ncalign_e;
pub const NCALIGN_LEFT: NcAlign_u32 = ffi::ncalign_e_NCALIGN_LEFT;
pub const NCALIGN_RIGHT: NcAlign_u32 = ffi::ncalign_e_NCALIGN_RIGHT;
pub const NCALIGN_TOP: NcAlign_u32 = NCALIGN_LEFT;
pub const NCALIGN_BOTTOM: NcAlign_u32 = NCALIGN_RIGHT;
pub const NCALIGN_CENTER: NcAlign_u32 = ffi::ncalign_e_NCALIGN_CENTER;
pub const NCALIGN_UNALIGNED: NcAlign_u32 = ffi::ncalign_e_NCALIGN_UNALIGNED;
}