Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Rust (Native Crate)

datalogic-rs is the core: everything the other bindings expose is implemented here. Using the crate directly gives you the full API ladder, including the zero-copy and tracing tiers no wrapper exposes.

Install

cargo add datalogic-rs

The default build has no dependency on serde_json and ships the 33 baseline operators. Opt into features as needed:

[dependencies]
datalogic-rs = { version = "5", features = ["serde_json", "datetime", "templating", "trace", "flagd"] }

See the feature matrix for what each flag adds.

Quick start

let result = datalogic_rs::eval_str(
    r#"{">": [{"var": "x"}, 10]}"#,
    r#"{"x": 42}"#,
).unwrap();
assert_eq!(result, "true");

Module-level helpers (eval, eval_str, eval_into, compile) are backed by a default engine, so one-off evaluation needs no setup.

Five tiers, one engine

The crate exposes a fine-grained API ladder; pick the tier matching your performance budget and trace requirements:

TierAPI Entry PointWhen to use
Tier 0eval_str, eval, eval_into, compileQuick scripts, simple tasks, one-off execution
Tier 1Engine::eval*Custom operators, non-default configs, templating mode
Tier 2Engine::session() + Session::eval*Hot loops (APIs, message queues, bulk pipelines); reuses internal bump arenas
Tier 3Engine::evaluate(&Logic, data, &Bump)Zero-copy evaluation with a caller-owned bumpalo::Bump arena
Tier 4Engine::trace()Full AST execution paths for debuggers and visualizers (trace feature)

Tiers 0–2 exist in every language binding; Tiers 3 and 4 are Rust-only.

Compile once, evaluate many

use datalogic_rs::Engine;

let engine = Engine::default();
let logic = engine.compile(r#"{">": [{"var": "x"}, 10]}"#).unwrap();

let mut session = engine.session();
for payload in inputs {
    let result = session.eval_str(&logic, payload).unwrap();
}

Compiled Logic is Send + Sync: share it across threads via Arc (or Engine::compile_arc). Sessions are cheap but not Sync; open one per thread. See Thread Safety for Tokio and rayon patterns.

Where everything else is documented