Module std::encoding::toml

TOML parsing.

Parse TOML documents into values, inspect types, extract fields, and serialize back to TOML text.

Examples

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();
}

Contents

Functions

Function parse

pub fn parse(s: String) -> Value

Parse a TOML string into a Value.

Panics if the input is not valid TOML.

Examples

let config = toml.parse("debug = true\nport = 8080");

Types

Struct Value

An opaque TOML value.

Represents any TOML type: String, integer, float, boolean, array, table, or datetime. Created by toml.parse(s) or by navigating into a parsed value. Must be freed with free() when no longer needed.

Traits

Trait ValueMethods

Methods available on a TOML Value.

Methods

fn type_of(self: Value) -> i32 fn get_string(self: Value) -> String fn get_int(self: Value) -> i64 fn get_float(self: Value) -> f64 fn get_bool(self: Value) -> i32 fn get_field(self: Value, key: String) -> Value fn array_len(self: Value) -> i32 fn array_get(self: Value, index: i32) -> Value fn stringify(self: Value) -> String fn free(self: Value)