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 settings;
|
||||
pub mod unit;
|
||||
|
||||
pub use settings::Settings;
|
||||
|
|
10
src/unit.h
10
src/unit.h
|
@ -9,11 +9,11 @@
|
|||
unit = NULL; \
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
UNIT_GLOBAL = 0,
|
||||
UNIT_MONITOR = 1,
|
||||
UNIT_TAG = 2,
|
||||
} UnitKind;
|
||||
typedef unsigned char UnitKind;
|
||||
|
||||
#define UNIT_GLOBAL 0
|
||||
#define UNIT_MONITOR 1
|
||||
#define UNIT_TAG 2
|
||||
|
||||
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