ErrorKind in std::io - Rust (original) (raw)
#[non_exhaustive]
pub enum ErrorKind {
Show 40 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,
FilesystemQuotaExceeded,
FileTooLarge,
ResourceBusy,
ExecutableFileBusy,
Deadlock,
CrossesDevices,
TooManyLinks,
FilenameTooLong,
ArgumentListTooLong,
Interrupted,
Unsupported,
UnexpectedEof,
OutOfMemory,
Other,
// some variants omitted
}
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.
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
An entity was not found, often a file.
The operation lacked the necessary privileges to complete.
The connection was refused by the remote server.
The connection was reset by the remote server.
🔬 This is a nightly-only experimental API. (io_error_more
#86442)
The remote host is not reachable.
🔬 This is a nightly-only experimental API. (io_error_more
#86442)
The network containing the remote host is not reachable.
The connection was aborted (terminated) by the remote server.
The network operation failed because it was not connected yet.
A socket address could not be bound because the address is already in use elsewhere.
A nonexistent interface was requested or the requested address was not local.
🔬 This is a nightly-only experimental API. (io_error_more
#86442)
The system’s networking is down.
The operation failed because a pipe was closed.
An entity already exists, often a file.
The operation needs to block to complete, but the blocking operation was requested to not occur.
🔬 This is a nightly-only experimental API. (io_error_more
#86442)
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.
🔬 This is a nightly-only experimental API. (io_error_more
#86442)
The filesystem object is, unexpectedly, a directory.
A directory was specified when a non-directory was expected.
🔬 This is a nightly-only experimental API. (io_error_more
#86442)
A non-empty directory was specified where an empty directory was expected.
🔬 This is a nightly-only experimental API. (io_error_more
#86442)
The filesystem or storage medium is read-only, but a write operation was attempted.
🔬 This is a nightly-only experimental API. (io_error_more
#86442)
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
🔬 This is a nightly-only experimental API. (io_error_more
#86442)
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.
A parameter was incorrect.
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 withInvalidData
if the file’s contents are not valid UTF-8.
The I/O operation’s timeout expired, causing it to be canceled.
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.
🔬 This is a nightly-only experimental API. (io_error_more
#86442)
The underlying storage (typically, a filesystem) is full.
This does not include out of quota errors.
🔬 This is a nightly-only experimental API. (io_error_more
#86442)
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
.
🔬 This is a nightly-only experimental API. (io_error_more
#86442)
Filesystem quota was exceeded.
🔬 This is a nightly-only experimental API. (io_error_more
#86442)
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.
🔬 This is a nightly-only experimental API. (io_error_more
#86442)
Resource is busy.
🔬 This is a nightly-only experimental API. (io_error_more
#86442)
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.)
🔬 This is a nightly-only experimental API. (io_error_more
#86442)
Deadlock (avoided).
A file locking operation would result in deadlock. This situation is typically detected, if at all, on a best-effort basis.
🔬 This is a nightly-only experimental API. (io_error_more
#86442)
Cross-device or cross-filesystem (hard) link or rename.
🔬 This is a nightly-only experimental API. (io_error_more
#86442)
Too many (hard) links to the same filesystem object.
The filesystem does not support making so many hardlinks to the same file.
🔬 This is a nightly-only experimental API. (io_error_more
#86442)
Filename too long.
The limit might be from the underlying filesystem or API, or an administratively imposed resource limit.
🔬 This is a nightly-only experimental API. (io_error_more
#86442)
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.
This operation was interrupted.
Interrupted operations can typically be retried.
This operation is unsupported on this platform.
This means that the operation can never succeed.
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.
An operation could not be completed, because it failed to allocate enough memory.
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 anyErrorKind.
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 match
ed on, and will only match a wildcard (_
) pattern. New ErrorKinds might be added in the future for some of those.
Formats the value using the given formatter. Read more
Intended for use for errors not exposed to the user, where allocating onto the heap (for normal construction via Error::new) is too costly.
Converts an ErrorKind into an Error.
This conversion allocates a new error with a simple representation of error kind.
use std::io::{Error, ErrorKind};
let not_found = ErrorKind::NotFound;
let error = Error::from(not_found);
assert_eq!("entity not found", format!("{}", error));
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Any for T where
T: 'static + ?Sized,
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
impl From for T
impl<T, U> Into for T where
U: From,
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
#41263)
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.