tabnas-dmog 0.4.0

The dmog library and command (data mogrify): translates a document from any tabnas format into any other, streaming, and runs alchemy programs over JSON documents, composing tabnas-alchemy, tabnas-transduce and tabnas-render.
Documentation

tabnas-dmog

The Rust build of dmog, a command that translates a document from one data format into another as it reads it, and runs programs in the alchemy language over JSON documents. It reads and writes 22 formats, among them CSV, JSON, TOML, XML, YAML, and the grammar notations ABNF, EBNF, and GBNF. The crate is also a library, which does the same for a Rust program.

The documentation is at dmog.tabnas.dev: a tutorial, how-to guides, the reference, and explanation.

Install

You need Rust 1.85 or later:

cargo install --locked tabnas-dmog

Use

Translate a YAML file to TOML:

dmog translate --from yaml --to toml server.yaml

Run an alchemy program over a JSON document:

dmog run table.alc records.json

Every command and option is in the command-line reference. The TypeScript, Go, and Rust builds take the same command line and are released together, at one version.

Use as a library

Add the crate to a project with cargo add tabnas-dmog. Its library is tabnas_dmog, and a document held in a string translates in one call:

use tabnas_dmog::{translate_str, Fail, TranslateOptions};

fn main() -> Result<(), Fail> {
    let yaml = "name: Ada\nlanguages: [en, fr]\n";
    let json = translate_str(yaml, TranslateOptions::new("yaml", "json"))?;
    assert_eq!(json, "{\"name\":\"Ada\",\"languages\":[\"en\",\"fr\"]}\n");
    Ok(())
}

Use the Rust library shows how to stream a file, run a program, read a failure, and stop a run. The API is on docs.rs, and it may change in any release before 1.0.

Licence

MIT. The source is at github.com/tabnas/dmog.