Skip to content
CryoCryo home
Stdlibencoding::toml

error

import std::encoding::toml::error; · source

Types

TomlError

type struct TomlError {
    kind:   TomlErrorKind;
    line:   u64;
    column: u64;
    offset: u64;
    msg:    String;
}

A kind, a position and a message, the same shape as JsonError. line and column are 1-indexed and offset is a 0-indexed byte offset into the source.

Properties

PropertyTypeNotes
kindTomlErrorKind
lineu641-indexed line of the offending byte; 0 for a value the writer refused.
columnu641-indexed column of the offending byte; 0 for a value the writer refused.
offsetu640-indexed byte offset into the source.
msgStringHuman-readable detail. Owned, and released with the error.

Constructors

static new(kind: TomlErrorKind, line: u64, column: u64, offset: u64, msg: String) -> TomlError;

An error of kind at the 1-indexed line and column, byte offset from the start of the source, explained by msg, which the error takes ownership of.

Methods

describe(&this) -> Str;

The human-readable message, borrowed for the error's lifetime; the kind and the position stay available as fields.

TomlErrorKind

type enum TomlErrorKind with [Eq, Clone] {
    UnexpectedEof;
    UnexpectedChar;
    InvalidEscape;
    InvalidNumber;
    InvalidDateTime;
    DuplicateKey;
    TableRedefined;
    DepthExceeded;
    NotRepresentable;
}

DuplicateKey and TableRedefined are TOML's own rules on defining keys and tables; NotRepresentable is the writer's refusal of a value TOML cannot spell: a document that is not a table, or a null in an array. label() gives a short diagnostic slug.

Variants
VariantNotes
UnexpectedEofThe input ended inside a value: an unclosed string, array or inline table, or a key with no value.
UnexpectedCharA character that cannot stand where it does: a key or value malformed, a control character, a missing line break.
InvalidEscapeA \X escape TOML does not define, or one naming no Unicode scalar value.
InvalidNumberA number TOML does not spell that way (01, 1__0, .5), or an integer no 64-bit signed integer holds.
InvalidDateTimeA date or time with a field out of its range (2023-02-30, 24:00:00) or a malformed one.
DuplicateKeyA key given a value twice in one table.
TableRedefinedA table defined twice, a table header naming a key that holds a value, or a table extended in a way TOML forbids: by a header after its dotted keys, or by dotted keys after its header.
DepthExceededArrays, inline tables and tables nested deeper than parser::MAX_DEPTH.
NotRepresentableA value the writer cannot write as TOML: a document that is not a table, or a null in an array.
Methods
label(&this) -> Str;

A short, stable slug for the kind: "unexpected_eof", "duplicate_key", ...

Trait implementations

implement trait Drop for struct TomlError
implement trait Display for struct TomlError
implement trait Debug for struct TomlError
implement trait Error for struct TomlError