Rule

Struct Rule 

Source
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: String

The unique name of the rule

§description: Option<String>

Optional description of what the rule does

§salience: i32

Priority of the rule (higher values execute first)

§enabled: bool

Whether the rule is enabled for execution

§no_loop: bool

Prevents the rule from activating itself in the same cycle

§lock_on_active: bool

Prevents 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: ConditionGroup

The 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

Source

pub fn new( name: String, conditions: ConditionGroup, actions: Vec<ActionType>, ) -> Self

Create a new rule with the given name, conditions, and actions

Source

pub fn with_description(self, description: String) -> Self

Add a description to the rule

Source

pub fn with_salience(self, salience: i32) -> Self

Set the salience (priority) of the rule

Source

pub fn with_priority(self, priority: i32) -> Self

Set the priority of the rule (alias for salience)

Source

pub fn with_no_loop(self, no_loop: bool) -> Self

Enable or disable no-loop behavior for this rule

Source

pub fn with_lock_on_active(self, lock_on_active: bool) -> Self

Enable or disable lock-on-active behavior for this rule

Source

pub fn with_agenda_group(self, agenda_group: String) -> Self

Set the agenda group for this rule

Source

pub fn with_activation_group(self, activation_group: String) -> Self

Set the activation group for this rule

Source

pub fn with_date_effective(self, date_effective: DateTime<Utc>) -> Self

Set the effective date for this rule

Source

pub fn with_date_expires(self, date_expires: DateTime<Utc>) -> Self

Set the expiration date for this rule

Source

pub fn with_date_effective_str(self, date_str: &str) -> Result<Self, ParseError>

Parse and set the effective date from ISO string

Source

pub fn with_date_expires_str(self, date_str: &str) -> Result<Self, ParseError>

Parse and set the expiration date from ISO string

Source

pub fn is_active_at(&self, timestamp: DateTime<Utc>) -> bool

Check if this rule is active at the given timestamp

Source

pub fn is_active(&self) -> bool

Check if this rule is currently active (using current time)

Source

pub fn matches(&self, facts: &HashMap<String, Value>) -> bool

Check if this rule matches the given facts

Trait Implementations§

Source§

impl Clone for Rule

Source§

fn clone(&self) -> Rule

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Rule

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.