TomlEventReader structv0.1.0
pub struct TomlEventReader {
// private fields
}
Constructors
TomlEventReader
pub func TomlEventReader(input: char8[..]) -> TomlEventReader
A reader over input.
| Name | Type | Description |
|---|---|---|
input | char8[..] | the text to read |
Returns: a reader positioned before the first event
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
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
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
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
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
Depth
pub func Depth(&self) -> uint
How deep inside arrays and inline tables the reader is.
Returns: how many tables are currently open
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
Related
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.
Cases
| Name | Value | Description |
|---|---|---|
HeaderStart | 2 | A [name] or [[name]] header opened; IsTableArray says which, and the key parts follow. |
HeaderEnd | 3 | The header's key path is complete. |
KeyStart | 4 | A key-value pair began; the key parts follow, and then the value. |
KeyPart | 5 | One part of a key path, whose span is the key as written. |
Text | 6 | A string value, still escaped as it was written. |
Integer | 7 | An integer, as written. |
Float | 8 | A float, as written. |
Boolean | 9 | true or false. |
DateTime | 10 | A date-time in any of the four forms, as written. |
ArrayStart | 11 | An array opened. |
ArrayEnd | 12 | An array closed. |
InlineTableStart | 13 | An inline table opened. |
InlineTableEnd | 14 | An inline table closed. |