#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum HaNotificationType {
PreEvent,
PostEvent,
}
impl HaNotificationType {
#[must_use]
pub const fn from_raw(value: i32) -> Self {
match value {
0 => Self::PreEvent,
_ => Self::PostEvent,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum SelectExecutedIn {
PrimaryEngine,
SecondaryEngine,
}
impl SelectExecutedIn {
#[must_use]
pub const fn from_raw(value: bool) -> Self {
if value {
Self::SecondaryEngine
} else {
Self::PrimaryEngine
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn notification_type_from_raw() {
assert_eq!(
HaNotificationType::from_raw(0),
HaNotificationType::PreEvent
);
assert_eq!(
HaNotificationType::from_raw(1),
HaNotificationType::PostEvent
);
assert_eq!(
HaNotificationType::from_raw(7),
HaNotificationType::PostEvent
);
}
#[test]
fn select_executed_in_from_raw() {
assert_eq!(
SelectExecutedIn::from_raw(false),
SelectExecutedIn::PrimaryEngine
);
assert_eq!(
SelectExecutedIn::from_raw(true),
SelectExecutedIn::SecondaryEngine
);
}
}