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

Failure

pub func Failure(self: &TomlEventReader) -> TomlParseFailure?

Why reading stopped, positioned, or none while nothing has gone wrong. This is what a caller asks after Next reports Error. A lexical refusal carries the lexer's own reason inside it rather than in a second call, so a caller holding the failure is holding all of it — and it is the same TomlParseFailure the tree parser answers, so the two ways of reading a document report a refusal in one vocabulary rather than two.

Returns: the failure, positioned at the token the reader stopped on, or none

Source

Span

pub func Span(self: &TomlEventReader) -> 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: &TomlEventReader) -> 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: &TomlEventReader) -> 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: &TomlEventReader) -> 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: &TomlEventReader) -> 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: &TomlEventReader) -> uint

How deep inside arrays and inline tables the reader is.

Returns: how many tables are currently open

Source

Next

pub func Next(self: &var TomlEventReader) -> TomlEvent

The next event, or End when the document is finished. After an Error every later call returns End: everything past a refusal would be read from a position the document never meant.

Returns: the next event, or the end-of-input event

Source

TomlEvent

pub enum TomlEvent: int32 {
    End = 0,
    Error = 1,
    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.

Source

Cases

NameValueDescription
End0The document is finished.
Error1Something went wrong; the reason is on the reader.
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.