#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use crate::common::compare_operator::CompareOperator;
use crate::db_parser::common_event::condition_type::ConditionType;
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(PartialEq, Clone)]
pub struct RunCondition {
operator: CompareOperator,
condition_type: ConditionType,
variable: u32,
value: u32,
}
impl RunCondition {
pub const fn new(
settings: u8,
variable: u32,
value: u32
) -> Self {
Self {
operator: CompareOperator::new((settings >> 4) & 0x0f),
condition_type: ConditionType::new(settings & 0x0f),
variable,
value
}
}
pub fn operator(&self) -> &CompareOperator {
&self.operator
}
pub fn condition_type(&self) -> &ConditionType {
&self.condition_type
}
pub fn variable(&self) -> u32 {
self.variable
}
pub fn value(&self) -> u32 {
self.value
}
}