Complete guide to all features in rust-rule-engine.
- Full Grule-compatible syntax
- File and string loading
- Automatic rule parsing
- Syntax validation
- Centralized rule storage
- Salience-based priority
- Rule lifecycle management
- Dynamic rule updates
- Rust's compile-time guarantees
- Strong typing for facts
- Type-safe rule execution
- Error handling at compile time
- Flexible key-value storage
- Nested object support
- Array handling
- Type coercion
Check if at least one fact matches:
when exists(Order.status == "pending")
then Alert.send("Pending orders found");
Check if no facts match:
when !exists(Error.critical == true)
then System.status = "healthy";
Check if all facts match:
when forall(Item.validated == true)
then Order.ready = true;
Combine with logical operators:
when
customer.tier == "gold" &&
exists(Order.amount > 1000) &&
!exists(Complaint.status == "open")
then
customer.priority = "high";
Control execution order:
rule "HighPriority" salience 100 { ... }
rule "Normal" salience 50 { ... }
rule "LowPriority" salience 1 { ... }
Prevent infinite self-triggering:
rule "UpdateStatus" no-loop {
when order.status == "pending"
then order.status = "processed";
}
Organize rules into phases:
rule "Validation" agenda-group "validate" { ... }
rule "Processing" agenda-group "process" { ... }
Mutually exclusive execution:
rule "Premium" activation-group "discount" salience 10 { ... }
rule "Standard" activation-group "discount" salience 5 { ... }
Time-based activation:
rule "Holiday"
date-effective "2025-12-01"
date-expires "2025-12-31" { ... }
engine.schedule_task("cleanup", Duration::from_secs(3600));let state = engine.get_workflow_state("order_processing");
println!("Progress: {:.2}%", state.progress);engine.set_workflow_data("stage", "approval");
// Rules in "approval" agenda-group auto-activateSee PLUGINS.md for complete list.
ToUpper(),ToLower(),Trim()Replace(),Substring()Contains(),StartsWith(),EndsWith()
Abs(),Round(),Ceil(),Floor()Max(),Min(),Pow(),Sqrt()Random(),RandomRange()
Now(),AddDays(),AddHours()FormatDate(),ParseDate()DayOfWeek(),IsWeekend()
IsEmail(),IsURL(),IsNumeric()IsAlpha(),InRange()MatchesPattern()
Full web API with endpoints for:
- Rule management (CRUD)
- Fact insertion
- Rule execution
- Analytics queries
- Rule execution metrics
- Performance monitoring
- Coverage analysis
- Live dashboards
- System health endpoints
- Plugin health monitoring
- Resource usage tracking
- Automatic fact cleanup
- Configurable retention
- Memory usage limits
- Automatic infinite loop detection
- Configurable max iterations
- Clear error messages
- Multi-threaded rule execution (optional)
- Thread-safe fact access
- Concurrent rule evaluation
- Lazy evaluation
- Short-circuit logic
- Efficient pattern matching
See Also:
- PLUGINS.md - Plugin system details
- ADVANCED_USAGE.md - Complex patterns
- RETE_GUIDE.md - RETE engine features
Last Updated: 2025-10-31 (v0.10.0)