v0.4.0

TomlEventReader structv0.1.0

Source
Reads a document as events, in order, without building a tree.
pub struct TomlEventReader {
    // private fields
}

Constructors

TomlEventReader

pub func TomlEventReader(input: char8[..]) -> TomlEventReader

A reader over input.

NameTypeDescription
inputchar8[..]the text to read

Returns: a reader positioned before the first event

Source

Methods

Span

pub func Span(&self) -> char8[..]

The bytes the current event's token spans, as written: a string is still escaped and a number is still text.

Returns: the raw text the current event covers, borrowed from the input

Source

Form

pub func Form(&self) -> TomlTextForm

Which string form the current text event was written in, which decoding it needs.

Returns: which quoting form the current text was written in

Source

Line

pub func Line(&self) -> uint

Which line the current event is on, counting from one.

Returns: the current event's line, counting from one

Source

Column

pub func Column(&self) -> uint

Which column the current event is at, counting from one, in bytes.

Returns: the current event's column, counting from one

Source

IsTableArray

pub func IsTableArray(&self) -> bool

Whether the header being read was written [[name]] rather than [name].

Returns: whether the current header opens an array of tables rather than a table

Source

Depth

pub func Depth(&self) -> uint

How deep inside arrays and inline tables the reader is.

Returns: how many tables are currently open

Source

Next

pub func Next(&var self) -> TomlEvent? throws TomlParseFailure

The next event, or none when the document is finished. A refusal is thrown as the same positioned TomlParseFailure the tree parser answers, so the two ways of reading a document report a refusal in one vocabulary; every later call throws it again, because everything past a refusal would be read from a position the document never meant.

Returns: the next event, or none at the end of the document

Source

TomlEvent

pub enum TomlEvent: int32 {
    HeaderStart = 2,
    HeaderEnd = 3,
    KeyStart = 4,
    KeyPart = 5,
    Text = 6,
    Integer = 7,
    Float = 8,
    Boolean = 9,
    DateTime = 10,
    ArrayStart = 11,
    ArrayEnd = 12,
    InlineTableStart = 13,
    InlineTableEnd = 14
}

What just happened in the document. The end of the document is none from Next, and a refusal is thrown.

Source

Cases

NameValueDescription
HeaderStart2A [name] or [[name]] header opened; IsTableArray says which, and the key parts follow.
HeaderEnd3The header's key path is complete.
KeyStart4A key-value pair began; the key parts follow, and then the value.
KeyPart5One part of a key path, whose span is the key as written.
Text6A string value, still escaped as it was written.
Integer7An integer, as written.
Float8A float, as written.
Boolean9true or false.
DateTime10A date-time in any of the four forms, as written.
ArrayStart11An array opened.
ArrayEnd12An array closed.
InlineTableStart13An inline table opened.
InlineTableEnd14An inline table closed.