ReteUlEngine

Struct ReteUlEngine 

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

RETE-UL Engine with cached nodes (Performance optimized!) This engine builds RETE nodes once and reuses them, avoiding expensive rebuilds

Implementations§

Source§

impl ReteUlEngine

Source

pub fn new() -> Self

Create new engine from Rule definitions (nodes are built and cached once)

Source

pub fn add_rule_with_action<F>( &mut self, name: String, node: ReteUlNode, priority: i32, no_loop: bool, action: F, )
where F: FnMut(&mut HashMap<String, String>) + 'static,

Add a rule with custom action closure

Source

pub fn add_rule_from_definition( &mut self, rule: &Rule, priority: i32, no_loop: bool, )

Add a rule from Rule definition (auto-build node once and cache)

Source

pub fn set_fact(&mut self, key: String, value: String)

Set a fact

Source

pub fn get_fact(&self, key: &str) -> Option<&String>

Get a fact

Source

pub fn remove_fact(&mut self, key: &str) -> Option<String>

Remove a fact

Source

pub fn get_all_facts(&self) -> &HashMap<String, String>

Get all facts

Source

pub fn clear_facts(&mut self)

Clear all facts

Source

pub fn fire_all(&mut self) -> Vec<String>

Fire all rules with agenda (using cached nodes - NO rebuild!)

Source

pub fn matches(&self, rule_name: &str) -> bool

Check if a specific rule matches current facts (without firing)

Source

pub fn get_matching_rules(&self) -> Vec<&str>

Get all matching rules (without firing)

Source

pub fn reset_fired_flags(&mut self)

Reset fired flags (allow rules to fire again)

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.