pub struct RuleEngine { /* private fields */ }Expand description
Integrated rule engine combining all reasoning modes
Implementations§
Source§impl RuleEngine
impl RuleEngine
pub fn new() -> Self
Sourcepub fn forward_chain(&mut self, facts: &[RuleAtom]) -> Result<Vec<RuleAtom>>
pub fn forward_chain(&mut self, facts: &[RuleAtom]) -> Result<Vec<RuleAtom>>
Perform forward chaining inference
Sourcepub fn backward_chain(&mut self, goal: &RuleAtom) -> Result<bool>
pub fn backward_chain(&mut self, goal: &RuleAtom) -> Result<bool>
Perform backward chaining to prove a goal
Sourcepub fn rete_forward_chain(
&mut self,
facts: Vec<RuleAtom>,
) -> Result<Vec<RuleAtom>>
pub fn rete_forward_chain( &mut self, facts: Vec<RuleAtom>, ) -> Result<Vec<RuleAtom>>
Perform RETE-based forward chaining
Sourcepub fn set_backward_chain_max_depth(&mut self, max_depth: usize)
pub fn set_backward_chain_max_depth(&mut self, max_depth: usize)
Set maximum proof depth for backward chaining
This limits the recursion depth to prevent stack overflow. Lower values (e.g., 20-30) are safer for large datasets. Default is 100.
Sourcepub fn set_cache(&mut self, cache: Option<RuleCache>)
pub fn set_cache(&mut self, cache: Option<RuleCache>)
Set cache for the rule engine
Enables or disables caching by setting the cache instance.
Pass Some(cache) to enable caching with a specific cache configuration,
or None to disable caching.
Sourcepub fn get_cache(&self) -> Option<&RuleCache>
pub fn get_cache(&self) -> Option<&RuleCache>
Get a reference to the cache
Returns a reference to the cache if enabled. The cache is wrapped in Option to allow disabling caching.
Sourcepub fn get_cache_mut(&mut self) -> Option<&mut RuleCache>
pub fn get_cache_mut(&mut self) -> Option<&mut RuleCache>
Get mutable reference to the cache
Returns a mutable reference to the cache if enabled. Useful for clearing cache, updating statistics, etc.
Sourcepub fn enable_cache(&mut self)
pub fn enable_cache(&mut self)
Enable caching with default settings
Creates a new cache with default configuration and enables it.
Sourcepub fn disable_cache(&mut self)
pub fn disable_cache(&mut self)
Disable caching
Removes the cache and disables caching functionality.
Sourcepub fn is_cache_enabled(&self) -> bool
pub fn is_cache_enabled(&self) -> bool
Check if caching is enabled
Sourcepub fn clear_cache(&mut self)
pub fn clear_cache(&mut self)
Clear the cache if enabled
Clears all cached rule results, derivations, unifications, and patterns.
Sourcepub fn get_cache_statistics(&self) -> Option<CachingStatistics>
pub fn get_cache_statistics(&self) -> Option<CachingStatistics>
Get cache statistics if caching is enabled
Returns combined statistics for all cache types (rule results, derivations, etc.)
Sourcepub fn warm_cache(&self, common_facts: &[RuleAtom])
pub fn warm_cache(&self, common_facts: &[RuleAtom])
Warm up the cache with current rules and common facts
Pre-populates the cache with patterns from the current rule set and provided common facts to improve initial query performance.
Trait Implementations§
Source§impl Debug for RuleEngine
impl Debug for RuleEngine
Auto Trait Implementations§
impl Freeze for RuleEngine
impl RefUnwindSafe for RuleEngine
impl Send for RuleEngine
impl Sync for RuleEngine
impl Unpin for RuleEngine
impl UnsafeUnpin for RuleEngine
impl UnwindSafe for RuleEngine
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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