pub struct Rule {
pub name: String,
pub description: Option<String>,
pub salience: i32,
pub enabled: bool,
pub no_loop: bool,
pub lock_on_active: bool,
pub agenda_group: Option<String>,
pub activation_group: Option<String>,
pub date_effective: Option<DateTime<Utc>>,
pub date_expires: Option<DateTime<Utc>>,
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
lock_on_active: boolPrevents the rule from firing again until agenda group changes
agenda_group: Option<String>Agenda group this rule belongs to (for workflow control)
activation_group: Option<String>Activation group - only one rule in group can fire
date_effective: Option<DateTime<Utc>>Rule becomes effective from this date
date_expires: Option<DateTime<Utc>>Rule expires after this date
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
Sourcepub fn with_lock_on_active(self, lock_on_active: bool) -> Self
pub fn with_lock_on_active(self, lock_on_active: bool) -> Self
Enable or disable lock-on-active behavior for this rule
Sourcepub fn with_agenda_group(self, agenda_group: String) -> Self
pub fn with_agenda_group(self, agenda_group: String) -> Self
Set the agenda group for this rule
Sourcepub fn with_activation_group(self, activation_group: String) -> Self
pub fn with_activation_group(self, activation_group: String) -> Self
Set the activation group for this rule
Sourcepub fn with_date_effective(self, date_effective: DateTime<Utc>) -> Self
pub fn with_date_effective(self, date_effective: DateTime<Utc>) -> Self
Set the effective date for this rule
Sourcepub fn with_date_expires(self, date_expires: DateTime<Utc>) -> Self
pub fn with_date_expires(self, date_expires: DateTime<Utc>) -> Self
Set the expiration date for this rule
Sourcepub fn with_date_effective_str(self, date_str: &str) -> Result<Self, ParseError>
pub fn with_date_effective_str(self, date_str: &str) -> Result<Self, ParseError>
Parse and set the effective date from ISO string
Sourcepub fn with_date_expires_str(self, date_str: &str) -> Result<Self, ParseError>
pub fn with_date_expires_str(self, date_str: &str) -> Result<Self, ParseError>
Parse and set the expiration date from ISO string
Sourcepub fn is_active_at(&self, timestamp: DateTime<Utc>) -> bool
pub fn is_active_at(&self, timestamp: DateTime<Utc>) -> bool
Check if this rule is active at the given timestamp
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more