pub struct RustRuleEngine { /* private fields */ }Expand description
Rust Rule Engine - High-performance rule execution engine
Implementations§
Source§impl RustRuleEngine
impl RustRuleEngine
Sourcepub fn execute_with_callback<F>(
&mut self,
facts: &Facts,
on_rule_fired: F,
) -> Result<GruleExecutionResult>
pub fn execute_with_callback<F>( &mut self, facts: &Facts, on_rule_fired: F, ) -> Result<GruleExecutionResult>
Execute all rules and call callback when a rule is fired
Sourcepub fn new(knowledge_base: KnowledgeBase) -> Self
pub fn new(knowledge_base: KnowledgeBase) -> Self
Create a new RustRuleEngine with default configuration
Sourcepub fn with_config(knowledge_base: KnowledgeBase, config: EngineConfig) -> Self
pub fn with_config(knowledge_base: KnowledgeBase, config: EngineConfig) -> Self
Create a new RustRuleEngine with custom configuration
Sourcepub fn register_function<F>(&mut self, name: &str, func: F)
pub fn register_function<F>(&mut self, name: &str, func: F)
Register a custom function
Sourcepub fn register_action_handler<F>(&mut self, action_type: &str, handler: F)
pub fn register_action_handler<F>(&mut self, action_type: &str, handler: F)
Register a custom action handler
Sourcepub fn enable_analytics(&mut self, analytics: RuleAnalytics)
pub fn enable_analytics(&mut self, analytics: RuleAnalytics)
Enable analytics with custom configuration
Sourcepub fn reset_no_loop_tracking(&mut self)
pub fn reset_no_loop_tracking(&mut self)
Reset global no-loop tracking (useful for testing or when facts change significantly)
Sourcepub fn disable_analytics(&mut self)
pub fn disable_analytics(&mut self)
Disable analytics
Sourcepub fn analytics(&self) -> Option<&RuleAnalytics>
pub fn analytics(&self) -> Option<&RuleAnalytics>
Get reference to analytics data
Sourcepub fn set_debug_mode(&mut self, enabled: bool)
pub fn set_debug_mode(&mut self, enabled: bool)
Enable debug mode for detailed execution logging
Sourcepub fn has_function(&self, name: &str) -> bool
pub fn has_function(&self, name: &str) -> bool
Check if a custom function is registered
Sourcepub fn has_action_handler(&self, action_type: &str) -> bool
pub fn has_action_handler(&self, action_type: &str) -> bool
Check if a custom action handler is registered
Sourcepub fn get_ready_tasks(&mut self) -> Vec<ScheduledTask>
pub fn get_ready_tasks(&mut self) -> Vec<ScheduledTask>
Get ready scheduled tasks
Sourcepub fn execute_scheduled_tasks(&mut self, facts: &Facts) -> Result<()>
pub fn execute_scheduled_tasks(&mut self, facts: &Facts) -> Result<()>
Execute scheduled tasks that are ready
Sourcepub fn activate_agenda_group(&mut self, group: String)
pub fn activate_agenda_group(&mut self, group: String)
Activate agenda group
Sourcepub fn knowledge_base(&self) -> &KnowledgeBase
pub fn knowledge_base(&self) -> &KnowledgeBase
Get the knowledge base
Sourcepub fn knowledge_base_mut(&mut self) -> &mut KnowledgeBase
pub fn knowledge_base_mut(&mut self) -> &mut KnowledgeBase
Get mutable reference to knowledge base
Sourcepub fn set_agenda_focus(&mut self, group: &str)
pub fn set_agenda_focus(&mut self, group: &str)
Set focus to a specific agenda group
Sourcepub fn get_active_agenda_group(&self) -> &str
pub fn get_active_agenda_group(&self) -> &str
Get the currently active agenda group
Sourcepub fn pop_agenda_focus(&mut self) -> Option<String>
pub fn pop_agenda_focus(&mut self) -> Option<String>
Pop the agenda focus stack
Sourcepub fn clear_agenda_focus(&mut self)
pub fn clear_agenda_focus(&mut self)
Clear all agenda focus and return to MAIN
Sourcepub fn get_agenda_groups(&self) -> Vec<String>
pub fn get_agenda_groups(&self) -> Vec<String>
Get all agenda groups that have rules
Sourcepub fn get_activation_groups(&self) -> Vec<String>
pub fn get_activation_groups(&self) -> Vec<String>
Get all activation groups that have rules
Sourcepub fn start_workflow(&mut self, workflow_name: Option<String>) -> String
pub fn start_workflow(&mut self, workflow_name: Option<String>) -> String
Start a new workflow
Sourcepub fn get_workflow_stats(&self) -> WorkflowStats
pub fn get_workflow_stats(&self) -> WorkflowStats
Get workflow statistics
Sourcepub fn get_workflow(&self, workflow_id: &str) -> Option<&WorkflowState>
pub fn get_workflow(&self, workflow_id: &str) -> Option<&WorkflowState>
Get workflow state by ID
Sourcepub fn cleanup_completed_workflows(&mut self, older_than: Duration)
pub fn cleanup_completed_workflows(&mut self, older_than: Duration)
Clean up completed workflows
Sourcepub fn execute_workflow_step(
&mut self,
agenda_group: &str,
facts: &Facts,
) -> Result<GruleExecutionResult>
pub fn execute_workflow_step( &mut self, agenda_group: &str, facts: &Facts, ) -> Result<GruleExecutionResult>
Execute workflow step by activating specific agenda group
Sourcepub fn execute_workflow(
&mut self,
agenda_groups: Vec<&str>,
facts: &Facts,
) -> Result<WorkflowResult>
pub fn execute_workflow( &mut self, agenda_groups: Vec<&str>, facts: &Facts, ) -> Result<WorkflowResult>
Execute a complete workflow by processing agenda groups sequentially
Sourcepub fn execute(&mut self, facts: &Facts) -> Result<GruleExecutionResult>
pub fn execute(&mut self, facts: &Facts) -> Result<GruleExecutionResult>
Execute all rules in the knowledge base against the given facts
Sourcepub fn execute_at_time(
&mut self,
facts: &Facts,
timestamp: DateTime<Utc>,
) -> Result<GruleExecutionResult>
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)
Sourcepub fn load_plugin(&mut self, plugin: Arc<dyn RulePlugin>) -> Result<()>
pub fn load_plugin(&mut self, plugin: Arc<dyn RulePlugin>) -> Result<()>
Load a plugin into the engine
Sourcepub fn unload_plugin(&mut self, name: &str) -> Result<()>
pub fn unload_plugin(&mut self, name: &str) -> Result<()>
Unload a plugin from the engine
Sourcepub fn hot_reload_plugin(
&mut self,
name: &str,
new_plugin: Arc<dyn RulePlugin>,
) -> Result<()>
pub fn hot_reload_plugin( &mut self, name: &str, new_plugin: Arc<dyn RulePlugin>, ) -> Result<()>
Hot reload a plugin
Sourcepub fn get_plugin_info(&self, name: &str) -> Option<&PluginMetadata>
pub fn get_plugin_info(&self, name: &str) -> Option<&PluginMetadata>
Get plugin information
Sourcepub fn list_plugins(&self) -> Vec<PluginInfo>
pub fn list_plugins(&self) -> Vec<PluginInfo>
List all loaded plugins
Sourcepub fn get_plugin_stats(&self) -> PluginStats
pub fn get_plugin_stats(&self) -> PluginStats
Get plugin statistics
Sourcepub fn plugin_health_check(&mut self) -> HashMap<String, PluginHealth>
pub fn plugin_health_check(&mut self) -> HashMap<String, PluginHealth>
Check health of all plugins
Sourcepub fn configure_plugins(&mut self, config: PluginConfig)
pub fn configure_plugins(&mut self, config: PluginConfig)
Configure plugin manager
Auto Trait Implementations§
impl Freeze for RustRuleEngine
impl !RefUnwindSafe for RustRuleEngine
impl Send for RustRuleEngine
impl Sync for RustRuleEngine
impl Unpin for RustRuleEngine
impl !UnwindSafe for RustRuleEngine
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
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