TomlScalarError variantv0.1.0

Source
Why a scalar could not be read, and where in it.
pub variant TomlScalarError {
    Malformed(uint),
    OutOfRange(uint),
    TooLong(uint)
}

Failure-only: there is no case meaning nothing went wrong, because a scalar that read hands back its value instead. Every offset is a zero-based byte offset into the scalar's own text, as the caller wrote it — underscores included — and reachable through Text::ParseFailure.

Cases

NameDescription
Malformed(uint)The text does not have the shape TOML defines, at the byte carried. That is the first character that cannot be part of what was being read: a digit the base does not have, a point with nothing after it, an underscore that is not between two digits, or the end of the text when it stops early.
OutOfRange(uint)The value is outside what an int64, a float64 or the calendar can hold. The offset is the start of the text, since it is the whole value that does not fit rather than any one character of it.
TooLong(uint)The text is longer than any TOML scalar needs. The offset is the first character past the bound.

Implements ParseFailure

TomlScalarError conforms to ParseFailure.

Offset

pub func Offset(self: &TomlScalarError) -> uint

Where in the scalar's text the failure was found. Borrows the failure and leaves it untouched. Cannot fail; runs in constant time and allocates nothing.

Returns: the zero-based byte offset into the scalar's own text

Source

Implements Display

TomlScalarError conforms to Display.

WriteDisplay

pub func WriteDisplay(
    self: &TomlScalarError,
    writer: &var TextWriter,
    spec: FormatSpec
) -> ! FormatError

Writes the description of why the scalar could not be read, without the position. The offset is a number a caller places where it makes sense for them — beside a line and column, or not at all — so it is not written into the middle of a sentence here. Debug carries it. Reports whatever the writer reported, and UnsupportedRequest for any style or precision.

NameTypeDescription
writer&var TextWriterthe destination
specFormatSpecwhat the placeholder asked for

Returns: success when the whole description was accepted

Source

Implements Debug

TomlScalarError conforms to Debug.

WriteDebug

pub func WriteDebug(
    self: &TomlScalarError,
    writer: &var TextWriter,
    spec: FormatSpec
) -> ! FormatError

Names the case and its position: TomlScalarError::Malformed(3). Reports whatever the writer reported, and UnsupportedRequest for any style or precision.

NameTypeDescription
writer&var TextWriterthe destination
specFormatSpecwhat the placeholder asked for

Returns: success when the whole name was accepted

Source