std::encoding::tomlTOML parsing and generation.
Parse TOML documents into values, build new tables programmatically, and serialize back to TOML text.
import std::encoding::toml;
fn main() {
let doc = toml.parse("[package]\nname = \"hew\"");
let pkg = doc.get_field("package");
let name = pkg.get_field("name");
println(name.get_string()); // "hew"
name.free();
pkg.free();
doc.free();
}
parseParse a TOML string into a Value.
Preserves the legacy behavior: invalid TOML returns an invalid handle
(type_of() == -1). Use try_parse for a structured error result.
try_parseParse a TOML string into a Value.
Returns Err(ParseError::Invalid(message)) with the native parser message
when parsing fails. Match on ParseError::Invalid(message) to recover the
original parser message.
ParseErrorStructured error type for TOML parsing failures.
Use Result<Value, ParseError> with try_parse for structured error
handling. Import std::encoding::toml when matching on the returned error
value so you can use the existing unqualified
ParseError::Invalid(message) constructor/pattern style.
Invalid(string)The input was not valid TOML. Carries the native parser message.
ValueAn opaque TOML value.
Represents any TOML type: string, integer, float, boolean, array,
table, or datetime. The canonical shared wire tag prefix reserves
0 for null, even though TOML itself has no null value. Must be freed
with free() when no longer needed.
ValueMethodsMethods available on a TOML Value.
Extends the shared opaque-handle contract from
std::encoding::wire::value_trait. Canonical methods are redeclared here
with TOML-specific docstrings for documentation purposes.
Return the type tag (0=null reserved, 1=bool, 2=i64, 3=float, 4=string, 5=array, 6=table, 7=datetime).
Extract the string value.
Extract the integer value.
Extract the floating-point value.
Extract the boolean value (0 or 1).
Look up a field by key in a TOML table.
Return the number of elements in a TOML array.
Return the element at the given index in a TOML array.
Serialize the value back to a TOML string.
Release the value resources.
Set a string field on a table. Returns the table for chaining.
Set an integer field. Returns the table for chaining.
Set a float field. Returns the table for chaining.
Set a boolean field. Returns the table for chaining.
Set a Value child on a table. The child is consumed. Returns the table.
Push a Value onto an array. The child is consumed. Returns the array.
Push an integer onto an array. Returns the array.
Push a string onto an array. Returns the array.
Push a float onto an array. Returns the array.
Push a boolean onto an array. Returns the array.