Reference · reference

data module

1 min read · 2026-09-02 · config-weave 0.1.0

use data parses and serializes INI files over the Value type. JSON, TOML and XML live in their own modules: json, toml and xml. Both functions return Result[…, string]. The parser accepts key=value lines and [section] headers, and rejects any other non-blank line with an error that names the line number.

ini_parse

rust
data::ini_parse(text: string) -> Result[Value, string]

Parses INI text into a map of sections. Each section is a map of its keys. Keys that appear before the first section header are placed under the empty-string section, which is dropped when it is empty.

ini_serialize

rust
data::ini_serialize(sections: Value) -> Result[string, string]

Serializes a map of sections to INI text. The value must be a map whose entries are maps; anything else is an error.

rust
use data
use fs

let cfg = data::ini_parse(fs::read("/etc/app/app.ini")?)?
let server = cfg.get("server")   // Option[Value], a map of the section's keys