[−][src]Enum restor::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(&self) -> 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]
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,