DecodeError variantv0.1.0
pub variant DecodeError {
InvalidCharacter(uint),
InvalidLength(uint),
InvalidPadding(uint),
NonCanonical(uint),
InvalidEscape(uint),
InsufficientCapacity(uint)
}
Failure-only: success is the other channel of uint ! DecodeError, so no case means that nothing went wrong.
Copy, carrying one count and owning nothing. A decoder that reports any case except InsufficientCapacity has
left its destination exactly as it was; see each decoder for what a capacity refusal leaves.
Cases
| Name | Description |
|---|---|
InvalidCharacter(uint) | A character that is not in the scheme's alphabet. The offset is that character. |
InvalidLength(uint) | The text has a length no encoder of this scheme produces, such as an odd number of hexadecimal digits. The offset is the text's length, where the missing character would have gone. |
InvalidPadding(uint) | A padding character where padding is not allowed: in the middle of the text, too much of it, or any of it in a scheme without padding. The offset is the first padding character that is out of place. |
NonCanonical(uint) | The last character carries bits the encoder would have left zero, so two different texts would decode to the same bytes. The offset is that character. Refusing it keeps decoding one-to-one, which is what makes an encoded value safe to compare as text. |
InvalidEscape(uint) | A percent sign that is not followed by two hexadecimal digits. The offset is the percent sign. |
InsufficientCapacity(uint) | The destination is shorter than the decoded value. The count is the length it needed, in bytes. |
Methods
Offset
pub func Offset(self: &DecodeError) -> uint?
Where in the text the failure was found, or none for a destination that was too short. Borrows the error and leaves it untouched. Cannot fail; runs in constant time and allocates nothing.
Returns: the zero-based byte offset into the text, or none for InsufficientCapacity
Implements Display
DecodeError conforms to Display.
WriteDisplay
pub func WriteDisplay(
self: &DecodeError,
writer: &var TextWriter,
spec: FormatSpec
) -> ! FormatError
Writes a short lower-case description, followed by the offset or the length needed.
The text is invalid character at 5 for an input failure and destination too short, need 12 bytes for a
capacity failure. No style is understood. Reports whatever the writer reported, and UnsupportedRequest for
a style.
| Name | Type | Description |
|---|---|---|
writer | &var TextWriter | the destination |
spec | FormatSpec | what the placeholder asked for |
Returns: success when the whole description was accepted
Implements Debug
DecodeError conforms to Debug.
WriteDebug
pub func WriteDebug(
self: &DecodeError,
writer: &var TextWriter,
spec: FormatSpec
) -> ! FormatError
The same text as Display: the description already names the case and its count.
The failures WriteDisplay reports.
| Name | Type | Description |
|---|---|---|
writer | &var TextWriter | the destination |
spec | FormatSpec | what the placeholder asked for |
Returns: success when the whole description was accepted