#[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;
}