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

Installation

Adding to Your Project

Pick your language. Each package carries the core crate’s version number (5.9.0 for this release):

// Cargo.toml
[dependencies]
datalogic-rs = "5"

Or run in terminal:
cargo add datalogic-rs
// npm
npm install @goplasmatic/datalogic-node # for Node.js services (native FFI)
# or:
npm install @goplasmatic/datalogic-wasm # for Browsers / Bun / Workers (WASM)
# pip
pip install datalogic-py
// go.mod
go get github.com/GoPlasmatic/datalogic-rs/bindings/go/v5
// Maven: pom.xml
<dependency>
    <groupId>io.github.goplasmatic</groupId>
    <artifactId>datalogic</artifactId>
    <version>5.9.0</version>
</dependency>

// Gradle: build.gradle.kts
implementation("io.github.goplasmatic:datalogic:5.9.0")
// dotnet CLI
dotnet add package Goplasmatic.Datalogic
// Composer
composer require goplasmatic/datalogic

The Rust crate builds without serde_json by default: the main entry points (Engine::eval_str, Engine::compile(&str), datalogic_rs::eval_str) take and return JSON text. Add the serde_json feature if you need serde_json::Value interop or the typed eval_into::<T> paths.

Feature Flags

The crate is a small core plus opt-in features. With default = [] you get the 33 JSONLogic core operators and no optional dependencies:

FeatureDefaultWhat it adds
serde_jsonoff&serde_json::Value interop (as EvalInput / IntoLogic) and the typed eval_into::<T> paths on Engine, Session, and the module-level helpers. Pulls in serde_json as a runtime dependency.
templatingoffTemplating mode: engine-wide with Engine::builder().with_templating(true).build(), or for one rule with Engine::compile_template.
datetimeoffdatetime, timestamp, parse_date, format_date, date_diff, now operators, including the optional trailing IANA-zone argument on format_date / parse_date (pulls in chrono and chrono-tz).
traceoffPer-evaluation execution tracing (engine.trace()…). Transitively enables serde_json.
ext-stringoffExtended string operators (length, starts_with, ends_with, upper, lower, trim, split).
ext-arrayoffExtended array operators (sort, slice, group_by, distinct).
ext-objectoffObject take-apart operators (keys, values, entries).
ext-controloffExtended control-flow operators (exists, ??, switch/match, type).
error-handlingofftry / throw operators.
ext-mathoffExtended math operators (abs, ceil, floor).
flagdoffOpenFeature flagd-compatible fractional (murmurhash3 percentage bucketing) and sem_ver (semantic-version comparison) operators.
wasm-clockoffJS-host clock for the now operator on wasm32-unknown-unknown (browsers, Node, Deno, Workers); combine with datetime. It forwards to chrono/wasmbind, whose JS imports fail to instantiate in non-JS wasm runtimes such as wasmtime, wazero and Chicory, so leave it off there (on WASI the OS clock works without it).
tensoroffThe Tensor value (dtype, shape and a row-major byte buffer) and 20 marshalling-only operators over it, for turning JSON into a model’s inputs and its outputs back into JSON. Constructors refuse more than 2^28 elements. No new dependency.
tensor-halfoffLifts the f16 / bf16 restriction on the element-wise tensor operators. Implies tensor; pulls in half.
budgetoffA per-evaluation operation counter with a hard abort and usage reports (EvaluationConfig::ops_budget, Engine::evaluate_metered / Engine::evaluate_metered_report, Session::eval_metered / Session::eval_metered_report, ErrorKind::BudgetExceeded). See Operation Budget.
all-operatorsoffEvery operator family at once: datetime, error-handling, the five ext-* families, flagd and tensor. A family added in a later release joins it. It does not include serde_json, templating, trace, budget, tensor-half or wasm-clock.

Example: opt into serde_json::Value interop plus templating:

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

Example: every operator, plus serde_json interop and templating (the official bindings use this set, plus trace and budget):

[dependencies]
datalogic-rs = { version = "5", features = ["all-operators", "serde_json", "templating"] }

A Cargo feature decides what is compiled in. To give one engine fewer operators than the build has, list the families it keeps with Engine::builder().with_families(..) (families in the bindings); see Configuration.

Version Selection

  • v5.x (current, 5.9.0): string-based API, opt-in serde_json, builder-only operator registration. v4 code has no compatibility shim in v5, so plan a single cutover.
  • v4.x: DataLogic engine with a serde_json::Value-first API. No longer the active line.
  • v3.x: the arena-based engine that v4 replaced.

If you’re upgrading from v4, or from an earlier 5.x release, see the Migration Guide.

Other languages

The Rust crate is the engine; each other language has its own binding over it. The binding’s guide covers install details and the API in that language:

LanguagePackageInstallDeep-dive
Node.js (native, napi-rs)@goplasmatic/datalogic-nodenpm i @goplasmatic/datalogic-nodeNode.js docs
JavaScript / TypeScript (WASM)@goplasmatic/datalogic-wasmnpm i @goplasmatic/datalogic-wasmJS / TS docs
Pythondatalogic-pypip install datalogic-pyPython docs
Godatalogic-gogo get github.com/GoPlasmatic/datalogic-rs/bindings/go/v5Go docs
JVM (Java, Kotlin, Scala)io.github.goplasmatic:datalogicio.github.goplasmatic:datalogic:5.9.0 (Maven Central, JDK 22+)Java / Kotlin docs
.NETGoplasmatic.Datalogicdotnet add package Goplasmatic.Datalogic.NET docs
PHPgoplasmatic/datalogiccomposer require goplasmatic/datalogicPHP docs
C ABI (any FFI host)datalogic-c (in-tree, not published)build bindings/c from sourceC ABI docs
React (visual debugger)@goplasmatic/datalogic-uinpm i @goplasmatic/datalogic-uiReact docs

Building the WASM binding from source:

cd bindings/wasm
./build.sh

Minimum Rust Version

datalogic-rs requires Rust 1.98 or later (the rust-version in its Cargo.toml). The floor comes from the datavalue-rs 0.3 dependency, which declares 1.98; the crate’s own code uses edition 2024 and needs less. The crate sets #![forbid(unsafe_code)].

Verifying Installation

Run a one-line evaluation to confirm the package loads:

// main.rs
fn main() {
    let result = datalogic_rs::eval_str(r#"{"+": [1, 2]}"#, r#"{}"#).unwrap();
    println!("1 + 2 = {}", result);
    assert_eq!(result, "3");
}
// Run in terminal: cargo run
// index.js
import { apply } from '@goplasmatic/datalogic-node';

const result = apply({ '+': [1, 2] }, {});
console.log(`1 + 2 = ${result}`); // 1 + 2 = 3
// browser/edge: same API via @goplasmatic/datalogic-wasm, see the WASM chapter
# test.py
from datalogic_py import apply

result = apply({"+": [1, 2]}, {})
print(f"1 + 2 = {result}") # 1 + 2 = 3
// main.go
package main

import (
    "fmt"
    datalogic "github.com/GoPlasmatic/datalogic-rs/bindings/go/v5"
)

func main() {
    result, _ := datalogic.Apply(`{"+": [1, 2]}`, `{}`)
    fmt.Printf("1 + 2 = %s\n", result) // 1 + 2 = 3
}
// Main.java
import com.goplasmatic.datalogic.Engine;

public class Main {
    public static void main(String[] args) {
        try (Engine engine = new Engine()) {
            String result = engine.apply("{\"+\": [1, 2]}", "{}");
            System.out.println("1 + 2 = " + result); // 1 + 2 = 3
        }
    }
}
// Program.cs
using Goplasmatic.Datalogic;

using var engine = new Engine();
var result = engine.Apply("""{"+": [1, 2]}""", "{}");
Console.WriteLine($"1 + 2 = {result}"); // 1 + 2 = 3
<?php // test.php
require 'vendor/autoload.php';

use Goplasmatic\Datalogic\Engine;

$engine = new Engine();
echo "1 + 2 = " . $engine->apply('{"+": [1, 2]}', '{}'); // 1 + 2 = 3

Next Steps