Skip to content
CryoCryo home
Stdlibfmt

error

import std::fmt::error; · source

Types

FmtError

type enum FmtError {
    Io(IoError);
    Alloc(AllocError);
}

implement enum FmtError {
    is_io(&this) -> boolean;
    is_alloc(&this) -> boolean;
    describe(&this) -> Str;
}

A formatted write can fail two ways, and collapsing them would throw away information a caller might want to branch on — a format that failed because String::push couldn't reallocate is not the same shape of problem as a closed socket. describe forwards to the wrapped error's own describe.

Variants

VariantNotes
Io(IoError)The byte sink rejected the write. IoError carries kind + errno.
Alloc(AllocError)A heap-backed sink (String, Array<u8>) could not grow.

Methods

is_io(&this) -> boolean;
is_alloc(&this) -> boolean;
describe(&this) -> Str;

A short, stable description of what went wrong, as a borrowed Str. The convergent accessor every stdlib error type exposes (describe(&this) -> Str); Display/Debug for FmtError delegate to it. Forwards to the wrapped error's own describe, so the variant (I/O vs allocation) is reflected without duplicating text here.

Trait implementations

implement trait From<IoError> for enum FmtError
implement trait From<AllocError> for enum FmtError
implement trait Display for enum FmtError
std::fmt::display
implement trait Debug for enum FmtError
std::fmt::display

The two From impls are the lifting conversions sink implementations use, which is what lets ? on an io::Write call inside a FmtWrite impl just work.