RustRuleEngine

Struct RustRuleEngine 

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

Rust Rule Engine - High-performance rule execution engine

Implementations§

Source§

impl RustRuleEngine

Source

pub fn new(knowledge_base: KnowledgeBase) -> Self

Create a new RustRuleEngine with default configuration

Source

pub fn with_config(knowledge_base: KnowledgeBase, config: EngineConfig) -> Self

Create a new RustRuleEngine with custom configuration

Source

pub fn register_function<F>(&mut self, name: &str, func: F)
where F: Fn(&[Value], &Facts) -> Result<Value> + Send + Sync + 'static,

Register a custom function

Source

pub fn register_action_handler<F>(&mut self, action_type: &str, handler: F)
where F: Fn(&HashMap<String, Value>, &Facts) -> Result<()> + Send + Sync + 'static,

Register a custom action handler

Source

pub fn enable_analytics(&mut self, analytics: RuleAnalytics)

Enable analytics with custom configuration

Source

pub fn reset_no_loop_tracking(&mut self)

Reset global no-loop tracking (useful for testing or when facts change significantly)

Source

pub fn disable_analytics(&mut self)

Disable analytics

Source

pub fn analytics(&self) -> Option<&RuleAnalytics>

Get reference to analytics data

Source

pub fn has_function(&self, name: &str) -> bool

Check if a custom function is registered

Source

pub fn has_action_handler(&self, action_type: &str) -> bool

Check if a custom action handler is registered

Source

pub fn knowledge_base(&self) -> &KnowledgeBase

Get reference to the knowledge base

Source

pub fn knowledge_base_mut(&mut self) -> &mut KnowledgeBase

Get mutable reference to the knowledge base

Source

pub fn set_agenda_focus(&mut self, group: &str)

Set focus to a specific agenda group

Source

pub fn get_active_agenda_group(&self) -> &str

Get the currently active agenda group

Source

pub fn pop_agenda_focus(&mut self) -> Option<String>

Pop the agenda focus stack

Source

pub fn clear_agenda_focus(&mut self)

Clear all agenda focus and return to MAIN

Source

pub fn get_agenda_groups(&self) -> Vec<String>

Get all agenda groups that have rules

Source

pub fn get_activation_groups(&self) -> Vec<String>

Get all activation groups that have rules

Source

pub fn execute(&mut self, facts: &Facts) -> Result<GruleExecutionResult>

Execute all rules in the knowledge base against the given facts

Source

pub fn execute_at_time( &mut self, facts: &Facts, timestamp: DateTime<Utc>, ) -> Result<GruleExecutionResult>

Execute all rules at a specific timestamp (for date-effective/expires testing)

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.