[][src]Enum restor::ErrorDesc

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

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.

Note

This implements BitAnd

Used for combining errors; This will combine certain errors into more concise errors.

Example

use restor::{ErrorDesc, UnitError};
let a = ErrorDesc::Unit(UnitError::OutOfBounds);
let b = ErrorDesc::BorrowedIncompatibly;
let combo = a & b;
assert_eq!(
    combo,
    ErrorDesc::Two(Box::new(
                (ErrorDesc::Unit(UnitError::OutOfBounds),
                 ErrorDesc::BorrowedIncompatibly)
    ))
);
let a = ErrorDesc::Unit(UnitError::IsNotMany);
let b = ErrorDesc::Unit(UnitError::IsNotOne);
assert_eq!(
    a & b,
    ErrorDesc::Unit(UnitError::IsNope)
);

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!
drop(x);
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.

Unit(UnitError)

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

Two(Box<(ErrorDesc, ErrorDesc)>)

The case where there were two errors

Trait Implementations

impl Clone for ErrorDesc[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl PartialEq<ErrorDesc> for ErrorDesc[src]

impl Debug for ErrorDesc[src]

impl BitAnd<ErrorDesc> for ErrorDesc[src]

type Output = Self

The resulting type after applying the & operator.

Auto Trait Implementations

impl Send for ErrorDesc

impl Sync for ErrorDesc

Blanket Implementations

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

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

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

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