Version: 1.11.0 Last Updated: December 10, 2024
Complete installation guide for Rust Rule Engine.
- Rust: 1.70.0 or higher
- Cargo: Latest stable version
Check your Rust version:
rustc --version
cargo --versionNeed to install Rust? → https://rustup.rs/
Add to your Cargo.toml:
[dependencies]
rust-rule-engine = "1.11"[dependencies.rust-rule-engine]
version = "1.11"
features = ["backward-chaining", "streaming"][dependencies]
rust-rule-engine = { git = "https://github.com/KSD-CO/rust-rule-engine", branch = "main" }| Feature | Description | Size Impact | Use Case |
|---|---|---|---|
| Default | Forward chaining + RETE | Minimal | Basic rule engine |
backward-chaining |
Goal-driven inference | +150KB | Queries & reasoning |
streaming |
Complex Event Processing | +100KB | Real-time events |
streaming-redis |
Redis state backend | +200KB | Distributed systems |
[dependencies]
rust-rule-engine = "1.11"Use for: Basic business rules, decision automation
[dependencies.rust-rule-engine]
version = "1.11"
features = ["backward-chaining", "streaming", "streaming-redis"]Use for: Enterprise applications, distributed systems
[dependencies.rust-rule-engine]
version = "1.11"
features = ["backward-chaining"]Use for: Diagnostic systems, expert systems
[dependencies.rust-rule-engine]
version = "1.11"
features = ["streaming"]Use for: IoT, real-time analytics, CEP
Create src/main.rs:
use rust_rule_engine::{Engine, Facts, Value};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut engine = Engine::new();
engine.add_rule_from_string(r#"
rule "Test" {
when
X == 1
then
Y = 2;
}
"#)?;
let mut facts = Facts::new();
facts.set("X", Value::Integer(1));
engine.run(&mut facts)?;
assert_eq!(facts.get("Y"), Some(&Value::Integer(2)));
println!("✅ Installation verified!");
Ok(())
}Run:
cargo runExpected output:
✅ Installation verified!
No additional setup required. Install and go!
cargo add rust-rule-engine
cargo buildNo additional setup required.
cargo add rust-rule-engine
cargo buildWorks out of the box. If you encounter issues with Redis features:
# Install Visual Studio Build Tools first
# Then:
cargo add rust-rule-engine --features backward-chaining,streaming
cargo buildFROM rust:1.75
WORKDIR /app
COPY Cargo.toml Cargo.lock ./
COPY src ./src
RUN cargo build --release --features backward-chaining,streaming
CMD ["./target/release/your-app"][dependencies.rust-rule-engine]
version = "1.11"
features = ["streaming-redis"]
[dependencies]
redis = "0.27"
tokio = { version = "1.42", features = ["full"] }Install Redis:
# macOS
brew install redis
brew services start redis
# Linux (Ubuntu/Debian)
sudo apt-get install redis-server
sudo systemctl start redis
# Docker
docker run -d -p 6379:6379 redis:latest[dependencies]
petgraph = "0.6" # Used by backward-chaining featureThis is automatically included with backward-chaining feature.
No breaking changes! Fully backward compatible.
# Update Cargo.toml
rust-rule-engine = "1.11"
# Update dependencies
cargo update
# Rebuild
cargo buildNew features available:
- Nested queries in backward chaining
- Query optimization (10-100x speedup)
cargo updateNew: Disjunction (OR) support in queries
Review Migration Guide for major version changes.
# Clone repository
git clone https://github.com/KSD-CO/rust-rule-engine
cd rust-rule-engine
# Build with all features
cargo build --all-features --release
# Run tests
cargo test --all-features
# Run examples
cargo run --example basic_usage# Clone and setup
git clone https://github.com/KSD-CO/rust-rule-engine
cd rust-rule-engine
# Install development dependencies
cargo install cargo-watch
cargo install cargo-tarpaulin
# Run in development mode with auto-reload
cargo watch -x "run --example basic_usage"
# Run tests with coverage
cargo tarpaulin --all-features# Code formatting
cargo install rustfmt
# Linting
cargo install clippy
# Documentation
cargo doc --open --all-features[profile.release]
opt-level = "z" # Optimize for size
lto = true # Link-time optimization
codegen-units = 1 # Better optimization
strip = true # Strip symbolsResult: ~2MB binary (forward chaining only)
Result: ~4MB binary (includes backward-chaining + streaming)
# Ensure you're using the correct version
cargo update
cargo clean
cargo buildCheck that you're using version 1.11+:
rust-rule-engine = "1.11"Install Redis separately or disable the feature:
features = ["backward-chaining", "streaming"]
# Remove "streaming-redis" if not needed# Reduce parallel jobs
cargo build -j 2✅ Installed? → Quick Start Guide
📚 Learn Concepts → Basic Concepts
🔨 Build Something → First Rules Tutorial
📖 API Reference → API Documentation
- License: MIT
- Repository: github.com/KSD-CO/rust-rule-engine
- Documentation: docs.rs/rust-rule-engine
- Crate: crates.io/crates/rust-rule-engine
📚 Documentation Home |