pub struct RulesEngine { /* private fields */ }Expand description
The rules engine evaluates rules against state changes.
Implementations§
Source§impl RulesEngine
impl RulesEngine
Sourcepub fn remove_rule(&mut self, id: &str) -> Result<()>
pub fn remove_rule(&mut self, id: &str) -> Result<()>
Remove a rule by ID
Sourcepub fn evaluate<F>(
&mut self,
address: &str,
value: &Value,
signal_type: SignalType,
origin: Option<&str>,
state_lookup: F,
) -> Vec<PendingAction>
pub fn evaluate<F>( &mut self, address: &str, value: &Value, signal_type: SignalType, origin: Option<&str>, state_lookup: F, ) -> Vec<PendingAction>
Evaluate rules triggered by a state change.
address: the address that changed
value: the new value
signal_type: Param or Event
origin: if set, skip rules that originated from this source (loop prevention)
state_lookup: function to look up current param values (for conditions)
Returns actions that should be executed by the router.
Sourcepub fn evaluate_interval<F>(
&mut self,
rule_id: &str,
state_lookup: F,
) -> Vec<PendingAction>
pub fn evaluate_interval<F>( &mut self, rule_id: &str, state_lookup: F, ) -> Vec<PendingAction>
Evaluate an interval rule by ID.
Unlike evaluate(), this doesn’t match on address/signal_type — it fires
the rule directly (checking enabled, cooldown, and conditions).
Returns actions that should be executed by the router.
Sourcepub fn interval_rules(&self) -> Vec<(String, u64)>
pub fn interval_rules(&self) -> Vec<(String, u64)>
Get rule IDs that have interval triggers (for the router to schedule)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RulesEngine
impl RefUnwindSafe for RulesEngine
impl Send for RulesEngine
impl Sync for RulesEngine
impl Unpin for RulesEngine
impl UnsafeUnpin for RulesEngine
impl UnwindSafe for RulesEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more