pub struct Rule {
pub name: String,
pub description: Option<String>,
pub salience: i32,
pub enabled: bool,
pub no_loop: bool,
pub conditions: ConditionGroup,
pub actions: Vec<ActionType>,
}Expand description
A rule with conditions and actions
Fields§
§name: StringThe unique name of the rule
description: Option<String>Optional description of what the rule does
salience: i32Priority of the rule (higher values execute first)
enabled: boolWhether the rule is enabled for execution
no_loop: boolPrevents the rule from activating itself in the same cycle
conditions: ConditionGroupThe conditions that must be met for the rule to fire
actions: Vec<ActionType>The actions to execute when the rule fires
Implementations§
Source§impl Rule
impl Rule
Sourcepub fn new(
name: String,
conditions: ConditionGroup,
actions: Vec<ActionType>,
) -> Self
pub fn new( name: String, conditions: ConditionGroup, actions: Vec<ActionType>, ) -> Self
Create a new rule with the given name, conditions, and actions
Sourcepub fn with_description(self, description: String) -> Self
pub fn with_description(self, description: String) -> Self
Add a description to the rule
Sourcepub fn with_salience(self, salience: i32) -> Self
pub fn with_salience(self, salience: i32) -> Self
Set the salience (priority) of the rule
Sourcepub fn with_priority(self, priority: i32) -> Self
pub fn with_priority(self, priority: i32) -> Self
Set the priority of the rule (alias for salience)
Sourcepub fn with_no_loop(self, no_loop: bool) -> Self
pub fn with_no_loop(self, no_loop: bool) -> Self
Enable or disable no-loop behavior for this rule
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Rule
impl RefUnwindSafe for Rule
impl Send for Rule
impl Sync for Rule
impl Unpin for Rule
impl UnwindSafe for Rule
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