packages

toml

0.1.0Official

TOML 1.1.0: Value tree with typed datetimes, parser with line:col errors, writer, typed encode/decode

published · MIT OR Apache-2.0 · 0 dependencies

Official: use toml::..; alone is enough, the first build adds it. Or:

nabi add toml

Then in your code

use toml::Value;
deps: {
    "toml": Dep::version("^0.1.0"),
},

CI packages.nabi-lang.org License: MIT OR Apache-2.0

TOML 1.1.0 for Nabi: a Value tree with typed date-times, a parser with line:col errors, a writer that lays documents out as people write them, and typed conversion with #[derive(Toml)]. The API follows std's nabion module: parse / to_str / from_str / to_value / from_value, with ToToml / FromToml traits.

Add it

nabi add toml

Needs Nabi 0.1 or later.

Usage

let doc = try toml::parse("title = \"demo\"\n\n[owner]\nname = \"Tom\"\n");
let owner = doc.get("owner") ?? toml::Value::Bool(false);
println(owner.get("name")?.as_str() ?? "");   // Tom
println(doc.to_str());                         // the document again

Derive Toml on your own types for typed from_str / to_str. parse reads TOML 1.1.0 by default; pass Version::V1_0 to read strictly as 1.0.

Docs

https://packages.nabi-lang.org/packages/toml/latest/docs

License

Licensed under either of MIT or Apache-2.0, at your option. The files under tests/ are from toml-test, MIT License, Copyright (c) 2018 TOML authors.

Readme from github.com/nabi-lang/toml at d79507b7.