LEPTRIS

Teptris — the crate v0.1.6

Hand-maintained FFI over libteptris v0.3.7 — no bindgen, no fallback. The safe API materializes the whole tree into an owned Value with insertion-ordered tables and real datetime fields; the engine's margin passes through almost intact.

Installation

bash
cargo add teptris

The crate is source + link directives: your build needslibteptris available and your runtime needs it findable (the binding is dynamically linked — the engine is not bundled). Install the engine (cmake --install puts it on the default loader path), or pointTEPTRIS_LIB_PATH at a directory containinglibteptris.{dylib,so,dll}. Theteptris-descriptor companion crate ships the no_std shared descriptor-plan ABI.

Usage

rust
use teptris::{loads, dump, dump_json_natural, Value};

let v = loads(b"name = \"demo\"\nport = 8080\n").unwrap();
assert_eq!(v.get("name").and_then(Value::as_str), Some("demo"));

let toml = dump(&v).unwrap();        // canonical; parse(dump(v)) == v
let json = dump_json_natural(&v).unwrap();
// real numbers, booleans, RFC 3339 datetime strings,
// non-finite floats as null — the host JSON view

Document::parse returns the zero-copy-managed document with to_toml_string,to_json_string (the toml-test conformance dialect) and to_json_natural_string. ParseErrorcarries the message plus 1-based line/column.

Descriptor plans

rust
use teptris::plan::{Descriptor, PlanRow};

let d = Descriptor::build(&[
    PlanRow::scalar("title"),
    PlanRow::collection("tags"),
    PlanRow::nested("owner", vec![
        PlanRow::scalar("name"),
        PlanRow::raw("meta"),
    ]),
])?;

let doc = teptris::Document::parse(b"title = 'd'
[owner]
name = 'r'
")?;
let v = d.walk(&doc)?; // only planned keys materialize

Compile a plan once, walk any number of documents in ONE native pass — unplanned keys are never materialized. MISSING rows are absent (rust has no null); raw rows re-use the plain node accessors on the untouched subtree.

Performance

Against toml 0.8 (the ecosystem standard, serde-based) over the engine bench corpus:7–45× faster on loads — datetime-heavy shapes 3.79 ms vs 168.89 ms, integer-heavy 6.25 ms vs 278.52 ms — and3–8× on dumps. It is the widest gap of any tier the family measures: there is no language-boundary tax comparable to the wasm bridge, so the C engine’s margin passes through intact. The lane runs in CI (cargo bench --bench tier, report-only).

Source — teptris-rs.

This is the curated guide. The repositories are canonical: when this page and the repo disagree, the repo wins. Full documentation lives with the source.