diff --git a/src/lib.rs b/src/lib.rs index 9b43eda..62f0b75 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,5 +3,6 @@ mod constraints; pub mod geom; pub mod settings; +pub mod unit; pub use settings::Settings; diff --git a/src/unit.h b/src/unit.h index 9d24398..6d54e87 100644 --- a/src/unit.h +++ b/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; diff --git a/src/unit.rs b/src/unit.rs new file mode 100644 index 0000000..41a0fd5 --- /dev/null +++ b/src/unit.rs @@ -0,0 +1,29 @@ +use std::os::raw::*; + +#[derive(Clone, Copy, Debug)] +pub enum Kind { + Global, + Monitor, + Tag, +} + +impl Into for Kind { + fn into(self) -> c_uchar { + match self { + Self::Global => 0, + Self::Monitor => 1, + Self::Tag => 2, + } + } +} + +impl From 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"), + } + } +}