BaseRule

Struct BaseRule 

Source
pub struct BaseRule { /* private fields */ }
Expand description

Base implementation for rules with callback support

Implementations§

Source§

impl BaseRule

Source

pub fn new() -> Self

Source

pub fn set_eval_fn<F>(&mut self, f: F)
where F: Fn(&RuleContext) -> RuleResult<bool> + 'static,

Set the evaluation function

Source

pub fn set_pre_execute_fn<F>(&mut self, f: F)
where F: Fn(&mut RuleContext) -> RuleResult<()> + 'static,

Set the pre-execution function

Source

pub fn set_execute_fn<F>(&mut self, f: F)
where F: Fn(&mut RuleContext) -> RuleResult<()> + 'static,

Set the execution function

Source

pub fn set_post_execute_fn<F>(&mut self, f: F)
where F: Fn(&mut RuleContext) -> RuleResult<()> + 'static,

Set the post-execution function

Trait Implementations§

Source§

impl Default for BaseRule

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Rule for BaseRule

Source§

fn evaluate(&self, context: &RuleContext) -> RuleResult<bool>

Evaluate if this rule should execute
Source§

fn execute(&mut self, context: &mut RuleContext) -> RuleResult<()>

Execute the rule with proper error handling
Source§

fn children(&self) -> &[Box<dyn Rule>]

Get immutable reference to children
Source§

fn children_mut(&mut self) -> &mut Vec<Box<dyn Rule>>

Get mutable reference to children
Source§

fn add_child(&mut self, child: Box<dyn Rule>) -> RuleResult<()>

Add a child rule
Source§

fn add_children(&mut self, children: Vec<Box<dyn Rule>>) -> RuleResult<()>

Add multiple child rules
Source§

fn fire(&mut self, context: &mut RuleContext) -> RuleResult<bool>

Execute the complete rule lifecycle: evaluate, execute, and run children

Auto Trait Implementations§

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> 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, 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.