Skip to content

Commit

Permalink
io: add error kinds from std.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirbaio committed Jul 12, 2023
1 parent 7aaa585 commit 7efe4be
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions embedded-io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,67 @@ pub enum SeekFrom {
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[non_exhaustive]
/// Possible kinds of errors.
///
/// This list is intended to grow over time and it is not recommended to
/// exhaustively match against it. In application code, use `match` for the `ErrorKind`
/// values you are expecting; use `_` to match "all other errors".
///
/// This is the `embedded-io` equivalent of [`std::io::ErrorKind`], except with the following changes:
///
/// - `WouldBlock` is removed, since `embedded-io` traits are always blocking. See the [crate-level documentation](crate) for details.
/// - `WriteZero` is removed, since it is a separate variant in [`WriteAllError`] and [`WriteFmtError`].
pub enum ErrorKind {
/// Unspecified error kind.
Other,

/// An entity was not found, often a file.
NotFound,
/// The operation lacked the necessary privileges to complete.
PermissionDenied,
/// The connection was refused by the remote server.
ConnectionRefused,
/// The connection was reset by the remote server.
ConnectionReset,
/// The connection was aborted (terminated) by the remote server.
ConnectionAborted,
/// The network operation failed because it was not connected yet.
NotConnected,
/// A socket address could not be bound because the address is already in
/// use elsewhere.
AddrInUse,
/// A nonexistent interface was requested or the requested address was not
/// local.
AddrNotAvailable,
/// The operation failed because a pipe was closed.
BrokenPipe,
/// An entity already exists, often a file.
AlreadyExists,
/// A parameter was incorrect.
InvalidInput,
/// 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.
///
/// [`InvalidInput`]: ErrorKind::InvalidInput
InvalidData,
/// The I/O operation's timeout expired, causing it to be canceled.
TimedOut,
/// This operation was interrupted.
///
/// Interrupted operations can typically be retried.
Interrupted,
/// This operation is unsupported on this platform.
///
/// This means that the operation can never succeed.
Unsupported,
/// An operation could not be completed, because it failed
/// to allocate enough memory.
OutOfMemory,
}

/// Error trait.
Expand Down

0 comments on commit 7efe4be

Please sign in to comment.