Error

Struct Error 

Source
pub struct Error(/* private fields */);
Expand description

Generic integer kernel error.

The kernel defines a set of integer generic error codes based on C and POSIX ones. These codes may have a more specific meaning in some contexts.

§Invariants

The value is a valid errno (i.e. >= -MAX_ERRNO && < 0).

Implementations§

Source§

impl Error

Source

pub fn from_errno(errno: c_int) -> Error

Creates an Error from a kernel error code.

errno must be within error code range (i.e. >= -MAX_ERRNO && < 0).

It is a bug to pass an out-of-range errno. code::EINVAL is returned in such a case.

§Examples
assert_eq!(Error::from_errno(-1), EPERM);
assert_eq!(Error::from_errno(-2), ENOENT);

The following calls are considered a bug:

assert_eq!(Error::from_errno(0), EINVAL);
assert_eq!(Error::from_errno(-1000000), EINVAL);
Source

pub fn to_errno(self) -> c_int

Returns the kernel error code.

Source

pub fn to_ptr<T>(self) -> *mut T

Returns the error encoded as a pointer.

Source

pub fn name(&self) -> Option<&'static CStr>

Returns a string representing the error, if one exists.

Trait Implementations§

Source§

impl Clone for Error

Source§

fn clone(&self) -> Error

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> From<AllocError<T>> for Error

Source§

fn from(insert_err: AllocError<T>) -> Error

Converts to this type from the input type.
Source§

impl From<AllocError> for Error

Source§

fn from(_: AllocError) -> Error

Converts to this type from the input type.
Source§

impl From<AllocErrorKind> for Error

Source§

fn from(kind: AllocErrorKind) -> Error

Converts to this type from the input type.
Source§

impl From<BadFdError> for Error

Source§

fn from(_: BadFdError) -> Error

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(_: Error) -> Error

Converts to this type from the input type.
Source§

impl From<FromBytesWithNulError> for Error

Source§

fn from(_: FromBytesWithNulError) -> Error

Converts to this type from the input type.
Source§

impl From<Infallible> for Error

Source§

fn from(e: Infallible) -> Error

Converts to this type from the input type.
Source§

impl<T> From<InsertError<T>> for Error

Source§

fn from(_: InsertError<T>) -> Error

Converts to this type from the input type.
Source§

impl<T> From<InsertError<T>> for Error

Source§

fn from(insert_err: InsertError<T>) -> Error

Converts to this type from the input type.