rusty-rules
A blazingly fast, flexible, and extensible rules engine written in Rust. Evaluate complex logical rules against custom data structures using a simple JSON-based DSL. Supports both synchronous and asynchronous fetchers, custom operators, and a variety of matchers.
Features
- Composable rules: Combine conditions with
all
,any
, andnot
logical blocks for complex rule hierarchies - Custom fetchers: Extract values from data structures with named fetchers that accept arguments
- Matcher support: String, regex, IP address, numeric, and boolean matchers out of the box
- Custom operators: Define operators for advanced matching and domain-specific logic
- Async support: Register async fetchers and operators for use with async/await contexts
- JSON-schema validation: Validate rules with automatically generated JSON schema (requires
validation
feature) - Thread-safety option: Optional
Send
/Sync
trait bounds with thesend
feature flag - Performance-focused: Designed for high-throughput rule evaluation with minimal overhead
Installation
Add to Cargo.toml
:
[]
= "0.2"
Basic Usage
Define context
use HashMap;
use IpAddr;
Register fetchers
use ;
let mut engine = new;
engine.register_fetcher;
engine.register_fetcher;
engine.register_fetcher;
// ...register other fetchers...
Compile and evaluate a rule
use json;
let rule = engine.compile_rule.unwrap;
let ctx = /* MyContext instance */;
assert!;