error
import std::io::error; · source
IoError
type struct IoError {
kind: IoErrorKind;
os_code: i32;
static new(kind: IoErrorKind, os_code: i32) -> IoError;
describe(&this) -> str::Str;
static from_errno(code: i32) -> IoError;
}
IoError carries the kind plus os_code, the underlying errno (or 0 where not applicable). Branch on the kind; keep the code for diagnostics. describe() -> Str is the standard accessor, and IoErrorKind::label() gives a stable slug like "not_found".
from_errno(code) does the mapping. Unknown codes fold to Other with the numeric value preserved.
IoErrorKind
type enum IoErrorKind {
NotFound;
PermissionDenied;
AlreadyExists;
ConnectionRefused;
ConnectionReset;
ConnectionAborted;
NotConnected;
AddrInUse;
AddrNotAvailable;
BrokenPipe;
Interrupted;
InvalidInput;
InvalidData;
TimedOut;
WriteZero;
UnexpectedEof;
WouldBlock;
OutOfMemory;
Unsupported;
Other;
}
implement enum IoErrorKind {
label(&this) -> string;
}
A small closed set of kinds, because callers mostly branch on the kind rather than the text.
The errno table is gated per OS. from_errno is fed msvcrt's C-runtime errno on Windows and glibc's on Linux; the base codes (1–34) are identical, but the socket range differs — EADDRINUSE is 98 on glibc and 100 on msvcrt — so those are gated. Socket errors on Windows do not pass through here at all; net::sys maps WSAGetLastError() codes directly. The named constants (ENOENT, EINTR, EPIPE, EADDRINUSE, ...) live in this module.
Trait implementations
implement trait Display for struct IoError // std::fmt::display
implement trait Debug for struct IoError // std::fmt::display