Add Rust type unit::Kind
This commit is contained in:
parent
1bf97dab72
commit
23c415dcde
|
@ -3,5 +3,6 @@ mod constraints;
|
||||||
|
|
||||||
pub mod geom;
|
pub mod geom;
|
||||||
pub mod settings;
|
pub mod settings;
|
||||||
|
pub mod unit;
|
||||||
|
|
||||||
pub use settings::Settings;
|
pub use settings::Settings;
|
||||||
|
|
10
src/unit.h
10
src/unit.h
|
@ -9,11 +9,11 @@
|
||||||
unit = NULL; \
|
unit = NULL; \
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef enum {
|
typedef unsigned char UnitKind;
|
||||||
UNIT_GLOBAL = 0,
|
|
||||||
UNIT_MONITOR = 1,
|
#define UNIT_GLOBAL 0
|
||||||
UNIT_TAG = 2,
|
#define UNIT_MONITOR 1
|
||||||
} UnitKind;
|
#define UNIT_TAG 2
|
||||||
|
|
||||||
typedef struct Unit *Unit;
|
typedef struct Unit *Unit;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
use std::os::raw::*;
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
pub enum Kind {
|
||||||
|
Global,
|
||||||
|
Monitor,
|
||||||
|
Tag,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<c_uchar> for Kind {
|
||||||
|
fn into(self) -> c_uchar {
|
||||||
|
match self {
|
||||||
|
Self::Global => 0,
|
||||||
|
Self::Monitor => 1,
|
||||||
|
Self::Tag => 2,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<c_uchar> for Kind {
|
||||||
|
fn from(value: c_uchar) -> Self {
|
||||||
|
match value {
|
||||||
|
0 => Self::Global,
|
||||||
|
1 => Self::Monitor,
|
||||||
|
2 => Self::Tag,
|
||||||
|
_ => panic!("invalid value for type Kind"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue