pub struct KnowledgeBase { /* private fields */ }Expand description
Knowledge Base - manages collections of rules and facts Similar to Grule’s KnowledgeBase concept
Implementations§
Source§impl KnowledgeBase
impl KnowledgeBase
Sourcepub fn new(name: &str) -> KnowledgeBase
pub fn new(name: &str) -> KnowledgeBase
Create a new knowledge base
Sourcepub fn add_rule(&self, rule: Rule) -> Result<(), RuleEngineError>
pub fn add_rule(&self, rule: Rule) -> Result<(), RuleEngineError>
Add a rule to the knowledge base
Sourcepub fn add_rules_from_grl(
&self,
grl_text: &str,
) -> Result<usize, RuleEngineError>
pub fn add_rules_from_grl( &self, grl_text: &str, ) -> Result<usize, RuleEngineError>
Add multiple rules from GRL text
Sourcepub fn remove_rule(&self, rule_name: &str) -> Result<bool, RuleEngineError>
pub fn remove_rule(&self, rule_name: &str) -> Result<bool, RuleEngineError>
Remove a rule by name
Sourcepub fn get_rule_names(&self) -> Vec<String>
pub fn get_rule_names(&self) -> Vec<String>
Get all rule names
Sourcepub fn rule_count(&self) -> usize
pub fn rule_count(&self) -> usize
Get rule count
Sourcepub fn set_rule_enabled(
&self,
rule_name: &str,
enabled: bool,
) -> Result<bool, RuleEngineError>
pub fn set_rule_enabled( &self, rule_name: &str, enabled: bool, ) -> Result<bool, RuleEngineError>
Enable or disable a rule
Sourcepub fn get_rules_snapshot(&self) -> Vec<Rule>
pub fn get_rules_snapshot(&self) -> Vec<Rule>
Get a snapshot of all rules (for execution)
Sourcepub fn get_statistics(&self) -> KnowledgeBaseStats
pub fn get_statistics(&self) -> KnowledgeBaseStats
Get knowledge base statistics
Sourcepub fn export_to_grl(&self) -> String
pub fn export_to_grl(&self) -> String
Export rules to GRL format
Trait Implementations§
Source§impl Clone for KnowledgeBase
impl Clone for KnowledgeBase
Source§fn clone(&self) -> KnowledgeBase
fn clone(&self) -> KnowledgeBase
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for KnowledgeBase
impl RefUnwindSafe for KnowledgeBase
impl Send for KnowledgeBase
impl Sync for KnowledgeBase
impl Unpin for KnowledgeBase
impl UnwindSafe for KnowledgeBase
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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