Reference · reference

toml module

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

use toml parses and serializes TOML over the Value type. config-weave registers it from wscript-std. Every function returns Result[…, string]. Serialization fails when the top-level value is not a map, and when a Value::Null appears anywhere, because TOML has no null. INI files are handled by the data module.

parse

rust
toml::parse(text: string) -> Result[Value, string]

Parses TOML text into a Value. Tables become maps and arrays become lists. Date and time values become strings.

to_string and to_string_pretty

rust
toml::to_string(value: Value) -> Result[string, string]
toml::to_string_pretty(value: Value) -> Result[string, string]

Serializes a map Value as TOML, in compact or in expanded form.

rust
use fs
use toml

let cfg = toml::parse(fs::read("/etc/app/config.toml")?)?
fs::write("/etc/app/config.toml", toml::to_string_pretty(cfg)?)?