pub trait Error: Debug + Display {
    // Provided methods
    fn source(&self) -> Option<&(dyn Error + 'static)> { ... }
    fn type_id(&self, _: Internal) -> TypeId
       where Self: 'static { ... }
}
Expand description

Error is a trait representing the basic expectations for error values, i.e., values of type E in Result<T, E>.

This is essentially a re-implementation of the Rust standard library’s std::error::Error trait. Because we cannot use std in the kernel, we must reimplement that trait in mycelium_util.

Errors must describe themselves through the Display and Debug traits, and may provide cause chain information:

The source method is generally used when errors cross “abstraction boundaries”. If one module must report an error that is caused by an error from a lower-level module, it can allow access to that error via the source method. This makes it possible for the high-level module to provide its own errors while also revealing some of the implementation for debugging via source chains.

Provided Methods§

source

fn source(&self) -> Option<&(dyn Error + 'static)>

The lower-level source of this error, if any.

This is equivalent to std::error::Error’s source method.

source

fn type_id(&self, _: Internal) -> TypeId
where Self: 'static,

Gets the TypeId of self.

Implementations§

source§

impl dyn Error + Send + 'static

source

pub fn is<T: Error + 'static>(&self) -> bool

Forwards to the method defined on the type dyn Error.

source

pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T>

Forwards to the method defined on the type dyn Error.

source

pub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T>

Forwards to the method defined on the type dyn Error.

source§

impl dyn Error + Send + Sync + 'static

source

pub fn is<T: Error + 'static>(&self) -> bool

Forwards to the method defined on the type dyn Error.

source

pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T>

Forwards to the method defined on the type dyn Error.

source

pub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T>

Forwards to the method defined on the type dyn Error.

source§

impl dyn Error

source

pub fn iter_chain(&self) -> ErrorIter<'_>

Returns an iterator starting with the current error and continuing with recursively calling source.

source

pub fn iter_sources(&self) -> ErrorIter<'_>

Returns an iterator starting with the source of this error and continuing with recursively calling source.

source§

impl dyn Error + 'static

source

pub fn is<T: Error + 'static>(&self) -> bool

Returns true if the boxed type is the same as T

source

pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T>

Returns some reference to the boxed value if it is of type T, or None if it isn’t.

source

pub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T>

Returns some mutable reference to the boxed value if it is of type T, or None if it isn’t.

Implementations on Foreign Types§

source§

impl Error for &'static str

Implementors§

source§

impl<E: Error + 'static> Error for Error<E>