pub mod scheduler;
pub mod poller;
pub mod condition {
use crate::domain::TriggerCondition;
use serde_json::Value;
pub struct ConditionEvaluator;
impl ConditionEvaluator {
pub fn evaluate_condition(&self, condition: &TriggerCondition, result: &Value) -> bool {
match condition {
TriggerCondition::NumericRange { min, max } => {
if let Some(num_val) = result.as_f64() {
num_val >= *min && num_val <= *max
} else {
false
}
}
TriggerCondition::StringContains { content } => {
if let Some(str_val) = result.as_str() {
str_val.contains(content)
} else {
false
}
}
TriggerCondition::StatusMatches { expected_status } => {
if let Some(status_val) = result.as_str() {
status_val == expected_status
} else {
false
}
}
TriggerCondition::CustomExpression { .. }
| TriggerCondition::ScheduleInterval { .. }
| TriggerCondition::ScheduleCron { .. } => {
false
}
}
}
}
}