| Crates.io | wirerust |
| lib.rs | wirerust |
| version | 0.1.0 |
| created_at | 2025-07-30 06:55:02.11543+00 |
| updated_at | 2025-07-30 06:55:02.11543+00 |
| description | A modular, embeddable filter engine for structured data |
| homepage | |
| repository | https://github.com/pyrowall/wirerust |
| max_upload_size | |
| id | 1773192 |
| size | 186,771 |
A high-performance, modular filter engine for structured data written in Rust. Wirerust provides a clean, extensible implementation for parsing, compiling, and executing filter expressions against runtime data with strong type safety and excellent performance.
β¨ Core Capabilities
π§ Supported Types
bool, int, bytes, stringip (IPv4/IPv6 addresses)array, map with type inferenceunknown for dynamic typingβ‘ Performance
Add to your Cargo.toml:
[dependencies]
wirerust = "0.1.0"
Basic usage:
use wirerust::{
WirerustEngineBuilder, FilterContext, LiteralValue, FieldType
};
// Create an engine with schema
let engine = WirerustEngineBuilder::new()
.field("status", FieldType::Int)
.field("method", FieldType::Bytes)
.field("path", FieldType::Bytes)
.build();
// Parse and compile a filter
let filter = engine.parse_and_compile("status == 200 && method == \"GET\"").unwrap();
// Create context with data
let mut ctx = FilterContext::new();
ctx.set("status", LiteralValue::Int(200), engine.schema()).unwrap();
ctx.set("method", LiteralValue::Bytes(b"GET".to_vec()), engine.schema()).unwrap();
// Execute the filter
assert!(filter.execute(&ctx).unwrap());
use wirerust::{FilterFunction, LiteralValue, WirerustEngineBuilder, FieldType};
struct CustomFilter;
impl FilterFunction for CustomFilter {
fn call(&self, args: &[LiteralValue]) -> Option<LiteralValue> {
// Your custom logic here
Some(LiteralValue::Bool(true))
}
}
let engine = WirerustEngineBuilder::new()
.field("data", FieldType::Bytes)
.register_function("custom_filter", CustomFilter)
.build();
// IP address filtering
let filter = engine.parse_and_compile(
"ip in [\"192.168.1.1\", \"10.0.0.1\"] && status >= 200 && status < 300"
).unwrap();
// String operations with functions
let filter = engine.parse_and_compile(
"starts_with(path, \"/api/\") && len(path) > 10"
).unwrap();
// Logical combinations
let filter = engine.parse_and_compile(
"(method == \"POST\" || method == \"PUT\") && status != 404"
).unwrap();
| Function | Description | Example |
|---|---|---|
len() |
Get length of string/array | len(name) > 5 |
starts_with() |
Check string prefix | starts_with(path, "/api/") |
ends_with() |
Check string suffix | ends_with(filename, ".json") |
sum() |
Sum array of numbers | sum(scores) > 100 |
upper() |
Convert to uppercase | upper(method) == "GET" |
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Filter String βββββΆβ AST (FilterExpr)βββββΆβ CompiledFilter β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ
β Type Checker β β Execution β
βββββββββββββββββββ βββββββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ
β Schema β β Context β
βββββββββββββββββββ βββββββββββββββββββ
Wirerust is designed for high-performance scenarios:
Benchmarks show excellent performance for typical filter operations.
git clone https://github.com/pyrowall/wirerust.git
cd wirerust
cargo test
# Run all tests
cargo test
# Run with all features
cargo test --all-features
# Run benchmarks
cargo bench
# Run clippy
cargo clippy --all-targets --all-features -- -D warnings
# Bump patch version (0.1.0 -> 0.1.1)
./scripts/bump-version.sh patch
# Bump minor version (0.1.0 -> 0.2.0)
./scripts/bump-version.sh minor
# Bump major version (0.1.0 -> 1.0.0)
./scripts/bump-version.sh major
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
cargo testcargo clippyThis project is licensed under either of
at your option.
Wirerust - Fast, safe, and extensible filtering for Rust applications.