Skip to main content

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 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Error

Source§

impl Debug for Error

Source§

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

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

impl Eq for Error

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.
Source§

impl From<InsertErrorKind> for Error

Source§

fn from(kind: InsertErrorKind) -> Error

Converts to this type from the input type.
Source§

impl From<LayoutError> for Error

Source§

fn from(_: LayoutError) -> Error

Converts to this type from the input type.
Source§

impl From<OutOfBound> for Error

Source§

fn from(_: OutOfBound) -> Self

Converts to this type from the input type.
Source§

impl<T> From<PushError<T>> for Error

Source§

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

Converts to this type from the input type.
Source§

impl From<RemoveError> for Error

Source§

fn from(_: RemoveError) -> Error

Converts to this type from the input type.
Source§

impl<T> From<StoreError<T>> for Error

Source§

fn from(value: StoreError<T>) -> Self

Converts to this type from the input type.
Source§

impl From<TryFromIntError> for Error

Source§

fn from(_: TryFromIntError) -> Error

Converts to this type from the input type.
Source§

impl From<Utf8Error> for Error

Source§

fn from(_: Utf8Error) -> Error

Converts to this type from the input type.
Source§

impl PartialEq for Error

Source§

fn eq(&self, other: &Error) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Error

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl UnwindSafe for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Init<T> for T

Source§

unsafe fn __init(self, slot: *mut T) -> Result<(), Infallible>

Initializes slot. Read more
Source§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> KnownSize for T

Source§

fn size(_: *const T) -> usize

Get the size of an object of this type in bytes, with the metadata of the given pointer.
Source§

impl<T> PinInit<T> for T

Source§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>

Initializes slot. Read more
Source§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>
where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U, const N: u32> TryIntoBounded<T, N> for U
where T: Integer, U: TryInto<T>,

Source§

fn try_into_bounded(self) -> Option<Bounded<T, N>>

Attempts to convert self into a Bounded using N bits. Read more
Source§

impl<T> Writer for T
where T: Debug,

Source§

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

Formats the value using the given formatter.