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
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
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
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
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
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
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
Depth
pub func Depth(self: &TomlEventReader) -> uint
How deep inside arrays and inline tables the reader is.
Returns: how many tables are currently open
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
Related
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.
Cases
| Name | Value | Description |
|---|---|---|
End | 0 | The document is finished. |
Error | 1 | Something went wrong; the reason is on the reader. |
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. |