[][src]Enum restor::ErrorDesc

pub enum ErrorDesc {
    BorrowedIncompatibly,
    NoAllocatedUnit,
    NoMatchingType,
    Inner(Box<ErrorDesc>),
    Unit(UnitError),
}

The basic error descriptions for why a dynamically typed resource operation didn't work. It does not contain however, the description for unit-related errors which handled with a UnitError by using the Unit variant of ErrorDesc.

Variants

BorrowedIncompatibly

Returned if there is an incompatible borrow on the contents of the unit. It follows the same rules for runtime checking as a RefCell<T>. Usually bundled with a Ref<T>/RefMut<T> in a Result<RefVariant<T>, ErrorDesc>.

Example:

let mut storage = DynamicStorage::new();
storage.allocate_for::<usize>();
storage.insert(0usize);
let x = storage.get::<usize>().unwrap();
let y = storage.get_mut::<usize>();
assert!(y.is_err());
NoAllocatedUnit

Returned when there is no unit allocated for the type that was requested. Allocate a unit to contain a <T> with DynamicStorage::allocate_for::<T>(&mut self). Note that <T> must be T: Sized + Any + 'static.

Example:

let mut storage = DynamicStorage::new();
let x = storage.get::<usize>();
assert!(x.is_err());
// Error, there is no unit for `usize` allocated!
storage.allocate_for::<usize>();
storage.insert::<usize>(10);
let x = storage.get::<usize>().unwrap();
assert_eq!(*x, 10);
NoMatchingType

This is an internal error that should be ignored by the user. This should never be created.

Inner(Box<ErrorDesc>)

This holds an inner ErrorDesc. Call unwrap on an Inner variant to get the inner error.

Unit(UnitError)

Contains an error specific to unit operations. Please refer to the UnitError documentation for more information.

Methods

impl ErrorDesc[src]

pub fn unwrap(self) -> ErrorDesc[src]

Consumes the ErrorDesc and returns an ErrorDesc if it's an Inner variant. Panics if it is not an ErrorDesc::Inner variant.

Trait Implementations

impl PartialEq<ErrorDesc> for ErrorDesc[src]

impl Debug for ErrorDesc[src]

Auto Trait Implementations

impl Send for ErrorDesc

impl Sync for ErrorDesc

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.