toml
On this page
TOML 1.1.0. parse reads a document into a Value table,
to_str writes one, and ToToml / FromToml (with
#[derive(Toml)]) map Nabi types to and from Value, as std's nabion
does for NABION.
Decode errors carry a path (.servers[1].port); from_str turns it
into line:col by re-reading the document up to that path, so the
happy path keeps no positions.
Modules
datetimeTOML date / time values (RFC 3339, with TOML's local forms).readTOML 1.1.0 reader: a recursive descent over the bytes of the document that builds the table tree as it goes, with each table's origin kept by path so redefinitions are caught.writeTOML text of a table: plain keys first, then[table]sections and[[array]]elements, each table under its full dotted header.
Re-exports
datetime::{Date, Time, Datetime}Source
pub use datetime::{Date, Time, Datetime}Structs
TomlErrorSource
pub struct TomlErrorA read or decode error. line / col (1-based, code points) are 0
when the value did not come from text; path names the failing part
(.servers[2].port, ."a b", empty at the root).
selfone level down:seg(.name,[3]) goes in front of the path.What went wrong, without the position.
1-based line, 0 when the value did not come from text.
1-based column in code points, 0 when the value did not come from text.
The failing part (
.servers[2].port), empty at the root.
Trait implementations 3
impl Display for TomlErrorimpl Debug for TomlErrorimpl Error for TomlError
OptionsSource
pub struct OptionsHow documents are written.
The forms the output may use. 1.1 adds
\e/\xHHescapes, times without zero seconds and inline tables over several lines. Default: 1.0, which every TOML reader takes.Columns an array or inline table may take before it is split over lines. Default: 100.
Enums
ValueSource
pub enum ValueA TOML value. A document is a Table; tables keep insertion order.
A table as a document; any other value as its inline text.
What kind of value this is, for messages.
Key
keyof a table.Item
iof an array.A number as
f64(an integer rounds to the nearest).
Trait implementations 1
impl Display for Value
VersionSource
pub enum VersionA TOML version. The names keep the version's dot as _.
Traits
ToTomlSource
pub trait ToTomlA Nabi value as TOML. none (from T | none) leaves the key out;
TOML has no null.
FromTomlSource
pub trait FromTomlA Nabi value from TOML; the target type decides how v reads.
A key of this type that the document leaves out: an error, except
T | none(none).
Functions
parseSource
pub fn parse(s: str, version: Version = Version::V1_1) throws (TomlError) -> Value Read one document into a Value::Table. version 1.0 rejects the
forms TOML 1.1 added.
to_strSource
pub fn to_str<T: ToToml>(x: T, opts: Options | none = none) -> str x as a TOML document. Panics unless x is written as a table, or
when a none sits in an array.
from_strSource
pub fn from_str<T: FromToml>(s: str) throws (TomlError) -> T Read a document as a T; errors carry the line:col of the part
that did not fit.
to_valueSource
pub fn to_value<T: ToToml>(x: T) -> Value x as a Value. Panics on none: it has no TOML form outside a
table, where to_str leaves the key out.
from_valueSource
pub fn from_value<T: FromToml>(v: Value) throws (TomlError) -> T v as a T.