toml
The toml module provides TOML serialization and deserialization.
Like json::read, toml::read uses type-directed deserialization.
/// Parse TOML from a string or bytes.
///
/// To parse a stream, read it first — `toml::read(Read::read_all(f)?)`.
val read: fn(input: [string, bytes]) -> Result<'b, [`TomlErr(string), `InvalidCast(string)]>;
/// Serialize a value to a TOML string.
val write_str: fn(?#pretty: bool, value: Any) -> Result<string, `TomlErr(string)>;
/// Serialize a value to TOML bytes.
///
/// To write to a stream, write the bytes — `Write::write_exact(f, toml::write_bytes(v)?)`.
val write_bytes: fn(?#pretty: bool, value: Any) -> Result<bytes, `TomlErr(string)>;
Example
type Config = {
host: string,
port: i64,
debug: bool
};
let cfg: Config = toml::read(sys::fs::read_all("config.toml")?)?;
let out = toml::write_str(#pretty: true, cfg)?;