Xo is experimental. The source is now public on GitHub, or try Xo in your browser.
Menu · toml

Docs

std/toml

On this page

Index

Types

TomlErr

struct TomlErr {
  line: Int
  msg: Str
}

Displays as toml: line 3: expected a value after =; an encode error has line 0 and displays as toml: msg.

Source: std/toml.xo:10

TomlErr.display

fn (e: TomlErr) display() -> Str

Source: std/toml.xo:15

DecodeErr

enum DecodeErr {
  Syntax(err: TomlErr)
  Value(err: json.DecodeErr)
}

Why decode failed: the text is not TOML, or its values do not fit T.

Source: std/toml.xo:34

DecodeErr.display

fn (e: DecodeErr) display() -> Str

Source: std/toml.xo:39

Functions

decode

fn decode[T: Json](text: Str) -> T ! DecodeErr

The document decoded into T by the rules of json.decode; a document that is not valid TOML is TomlErr.

Source: std/toml.xo:19

to_json

fn to_json(text: Str) -> Str ! TomlErr

The document as JSON text, its keys in document order.

Source: std/toml.xo:21

encode

fn encode[T: Json](v: T) -> Str ! TomlErr

v as a TOML document, laid out as pelletier/go-toml/v2’s Marshal: a table’s plain keys first, then its tables ([a.b], a blank line before each) and arrays of tables ([[a]]) in field order; strings as literal strings (’…’) when they can be, else basic strings with Go’s escapes; an array of values or mixed values inline. v goes through json.to_value, so a None field is left out, Time and Duration are their JSON strings, and a Float with no fraction is an integer (decode reads each back). TomlErr (line 0) when v is not a record or map, or an array holds a None.

Source: std/toml.xo:31

↑ index