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

Select your target language to see package installation instructions:

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

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.1.0</version>
</dependency>

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

Note for Rust users: v5 does not require serde_json by default — the canonical entry points (Engine::eval_str, Engine::compile(&str), datalogic_rs::eval_str) are string-based. Add the serde_json feature only if you need serde_json::Value interop or the typed eval_into::<T> paths.

Feature Flags

v5 splits the surface into a small core plus opt-in features:

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::builder().with_templating(true).build().
datetimeoffdatetime, timestamp, parse_date, format_date, date_diff, now operators (pulls in chrono).
traceoffPer-evaluation execution tracing (engine.trace()…). Transitively enables serde_json.
ext-stringoffExtended string operators.
ext-arrayoffExtended array operators (e.g. sort).
ext-controloffExtended control-flow operators (exists, ??, switch/match, type).
error-handlingofftry / throw operators.
ext-mathoffExtended math operators.
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. Opt-in on purpose: it forwards to chrono/wasmbind, whose JS imports fail to instantiate in non-JS wasm runtimes such as wasmtime, wazero, and Chicory — leave it off there (on WASI the OS clock works without it).

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

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

Version Selection

  • v5.x (current): canonical string-based API, opt-in serde_json, builder-only operator registration. v5 is a hard cliff — no compat shim — so plan a single cutover.
  • v4.x: DataLogic engine, serde_json::Value-first API. Still functional but no longer the active line.
  • v3.x: Arena-based allocation, predates the v4 simplification. Bug-fix only.

If you’re upgrading from v4, see the Migration Guide.

Other languages

The Rust crate is the engine; every other language uses its own binding. Click through to the binding’s guide for install instructions and the language-idiomatic API:

LanguagePackageInstallDeep-dive
Node.js (native, napi-rs)@goplasmatic/datalogic-nodenpm i @goplasmatic/datalogic-nodeNode native README
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:datalogicMaven Central dependencyJava / Kotlin docs
.NETGoplasmatic.Datalogicdotnet add package Goplasmatic.Datalogic.NET docs
PHPgoplasmatic/datalogiccomposer require goplasmatic/datalogicPHP 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 v5 uses Rust edition 2024 — Rust 1.85 or later is required. The crate is built with #![forbid(unsafe_code)].

Verifying Installation

Create a simple script or test file to verify everything works:

// 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.0
// 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