#[non_exhaustive]pub enum ErrorKind {
Show 41 variants
NotFound,
PermissionDenied,
ConnectionRefused,
ConnectionReset,
HostUnreachable,
NetworkUnreachable,
ConnectionAborted,
NotConnected,
AddrInUse,
AddrNotAvailable,
NetworkDown,
BrokenPipe,
AlreadyExists,
WouldBlock,
NotADirectory,
IsADirectory,
DirectoryNotEmpty,
ReadOnlyFilesystem,
FilesystemLoop,
StaleNetworkFileHandle,
InvalidInput,
InvalidData,
TimedOut,
WriteZero,
StorageFull,
NotSeekable,
QuotaExceeded,
FileTooLarge,
ResourceBusy,
ExecutableFileBusy,
Deadlock,
CrossesDevices,
TooManyLinks,
InvalidFilename,
ArgumentListTooLong,
Interrupted,
Unsupported,
UnexpectedEof,
OutOfMemory,
InProgress,
Other,
}core_io)Expand description
A list specifying general categories of I/O error.
This list is intended to grow over time and it is not recommended to exhaustively match against it.
It is used with the io::Error type.
ยงHandling errors and matching on ErrorKind
In application code, use match for the ErrorKind values you are
expecting; use _ to match โall other errorsโ.
In comprehensive and thorough tests that want to verify that a test doesnโt
return any known incorrect error kind, you may want to cut-and-paste the
current full list of errors from here into your test code, and then match
_ as the correct case. This seems counterintuitive, but it will make your
tests more robust. In particular, if you want to verify that your code does
produce an unrecognized error kind, the robust solution is to check for all
the recognized error kinds and fail in those cases.
Variants (Non-exhaustive)ยง
This enum is marked as non-exhaustive
NotFound
core_io)An entity was not found, often a file.
PermissionDenied
core_io)The operation lacked the necessary privileges to complete.
ConnectionRefused
core_io)The connection was refused by the remote server.
ConnectionReset
core_io)The connection was reset by the remote server.
HostUnreachable
core_io)The remote host is not reachable.
NetworkUnreachable
core_io)The network containing the remote host is not reachable.
ConnectionAborted
core_io)The connection was aborted (terminated) by the remote server.
NotConnected
core_io)The network operation failed because it was not connected yet.
AddrInUse
core_io)A socket address could not be bound because the address is already in use elsewhere.
AddrNotAvailable
core_io)A nonexistent interface was requested or the requested address was not local.
NetworkDown
core_io)The systemโs networking is down.
BrokenPipe
core_io)The operation failed because a pipe was closed.
AlreadyExists
core_io)An entity already exists, often a file.
WouldBlock
core_io)The operation needs to block to complete, but the blocking operation was requested to not occur.
NotADirectory
core_io)A filesystem object is, unexpectedly, not a directory.
For example, a filesystem path was specified where one of the intermediate directory components was, in fact, a plain file.
IsADirectory
core_io)The filesystem object is, unexpectedly, a directory.
A directory was specified when a non-directory was expected.
DirectoryNotEmpty
core_io)A non-empty directory was specified where an empty directory was expected.
ReadOnlyFilesystem
core_io)The filesystem or storage medium is read-only, but a write operation was attempted.
FilesystemLoop
io_error_more)Loop in the filesystem or IO subsystem; often, too many levels of symbolic links.
There was a loop (or excessively long chain) resolving a filesystem object or file IO object.
On Unix this is usually the result of a symbolic link loop; or, of exceeding the system-specific limit on the depth of symlink traversal.
StaleNetworkFileHandle
core_io)Stale network file handle.
With some network filesystems, notably NFS, an open file (or directory) can be invalidated by problems with the network or server.
InvalidInput
core_io)A parameter was incorrect.
InvalidData
core_io)Data not valid for the operation were encountered.
Unlike InvalidInput, this typically means that the operation
parameters were valid, however the error was caused by malformed
input data.
For example, a function that reads a file into a string will error with
InvalidData if the fileโs contents are not valid UTF-8.
TimedOut
core_io)The I/O operationโs timeout expired, causing it to be canceled.
WriteZero
core_io)An error returned when an operation could not be completed because a
call to write returned Ok(0).
This typically means that an operation could only succeed if it wrote a particular number of bytes but only a smaller number of bytes could be written.
StorageFull
core_io)The underlying storage (typically, a filesystem) is full.
This does not include out of quota errors.
NotSeekable
core_io)Seek on unseekable file.
Seeking was attempted on an open file handle which is not suitable for seeking - for
example, on Unix, a named pipe opened with File::open.
QuotaExceeded
core_io)Filesystem quota or some other kind of quota was exceeded.
FileTooLarge
core_io)File larger than allowed or supported.
This might arise from a hard limit of the underlying filesystem or file access API, or from an administratively imposed resource limitation. Simple disk full, and out of quota, have their own errors.
ResourceBusy
core_io)Resource is busy.
ExecutableFileBusy
core_io)Executable file is busy.
An attempt was made to write to a file which is also in use as a running program. (Not all operating systems detect this situation.)
Deadlock
core_io)Deadlock (avoided).
A file locking operation would result in deadlock. This situation is typically detected, if at all, on a best-effort basis.
CrossesDevices
core_io)Cross-device or cross-filesystem (hard) link or rename.
TooManyLinks
core_io)Too many (hard) links to the same filesystem object.
The filesystem does not support making so many hardlinks to the same file.
InvalidFilename
core_io)A filename was invalid.
This error can also occur if a length limit for a name was exceeded.
ArgumentListTooLong
core_io)Program argument list too long.
When trying to run an external program, a system or process limit on the size of the arguments would have been exceeded.
Interrupted
core_io)This operation was interrupted.
Interrupted operations can typically be retried.
Unsupported
core_io)This operation is unsupported on this platform.
This means that the operation can never succeed.
UnexpectedEof
core_io)An error returned when an operation could not be completed because an โend of fileโ was reached prematurely.
This typically means that an operation could only succeed if it read a particular number of bytes but only a smaller number of bytes could be read.
OutOfMemory
core_io)An operation could not be completed, because it failed to allocate enough memory.
InProgress
io_error_inprogress)The operation was partially successful and needs to be checked later on due to not blocking.
Other
core_io)A custom error that does not fall under any other I/O error kind.
This can be used to construct your own Errors that do not match any
ErrorKind.
This ErrorKind is not used by the standard library.
Errors from the standard library that do not fall under any of the I/O
error kinds cannot be matched on, and will only match a wildcard (_) pattern.
New ErrorKinds might be added in the future for some of those.
Trait Implementationsยง
1.60.0 ยท Sourceยงimpl Display for ErrorKind
impl Display for ErrorKind
1.14.0 ยท Sourceยงimpl From<ErrorKind> for Error
Intended for use for errors not exposed to the user, where allocating onto
the heap (for normal construction via Error::new) is too costly.
impl From<ErrorKind> for Error
Intended for use for errors not exposed to the user, where allocating onto the heap (for normal construction via Error::new) is too costly.
1.0.0 ยท Sourceยงimpl Ord for ErrorKind
impl Ord for ErrorKind
1.21.0 (const: unstable) ยท Sourceยงfn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.0.0 ยท Sourceยงimpl PartialEq for ErrorKind
impl PartialEq for ErrorKind
1.0.0 ยท Sourceยงimpl PartialOrd for ErrorKind
impl PartialOrd for ErrorKind
impl Copy for ErrorKind
impl Eq for ErrorKind
impl StructuralPartialEq for ErrorKind
Auto Trait Implementationsยง
impl Freeze for ErrorKind
impl RefUnwindSafe for ErrorKind
impl Send for ErrorKind
impl Sync for ErrorKind
impl Unpin for ErrorKind
impl UnsafeUnpin for ErrorKind
impl UnwindSafe for ErrorKind
Blanket Implementationsยง
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Sourceยงimpl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Sourceยงfn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Sourceยงfn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Sourceยงfn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Anyโs vtable from &Traitโs.Sourceยงfn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Anyโs vtable from &mut Traitโs.Sourceยงimpl<T> DowncastSync for T
impl<T> DowncastSync for T
Sourceยงimpl<A> DynCastExt for A
impl<A> DynCastExt for A
Sourceยงfn dyn_cast<T>(
self,
) -> Result<<A as DynCastExtHelper<T>>::Target, <A as DynCastExtHelper<T>>::Source>where
A: DynCastExtHelper<T>,
T: ?Sized,
fn dyn_cast<T>(
self,
) -> Result<<A as DynCastExtHelper<T>>::Target, <A as DynCastExtHelper<T>>::Source>where
A: DynCastExtHelper<T>,
T: ?Sized,
Sourceยงfn dyn_upcast<T>(self) -> <A as DynCastExtAdvHelper<T, T>>::Target
fn dyn_upcast<T>(self) -> <A as DynCastExtAdvHelper<T, T>>::Target
Sourceยงfn dyn_cast_adv<F, T>(
self,
) -> Result<<A as DynCastExtAdvHelper<F, T>>::Target, <A as DynCastExtAdvHelper<F, T>>::Source>
fn dyn_cast_adv<F, T>( self, ) -> Result<<A as DynCastExtAdvHelper<F, T>>::Target, <A as DynCastExtAdvHelper<F, T>>::Source>
Sourceยงfn dyn_cast_with_config<C>(
self,
) -> Result<<A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Target, <A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Source>where
C: DynCastConfig,
A: DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>,
fn dyn_cast_with_config<C>(
self,
) -> Result<<A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Target, <A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Source>where
C: DynCastConfig,
A: DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>,
Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงfn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงfn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Sourceยงimpl<T> Instrument for T
impl<T> Instrument for T
Sourceยงfn instrument(self, span: Span) -> Instrumented<Self> โ
fn instrument(self, span: Span) -> Instrumented<Self> โ
Sourceยงfn in_current_span(self) -> Instrumented<Self> โ
fn in_current_span(self) -> Instrumented<Self> โ
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self> โ
fn into_either(self, into_left: bool) -> Either<Self, Self> โ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more