pub enum Error {
Id(Error),
Expression(Error),
Other(Box<dyn Error + Send + 'static>),
}Expand description
Module error.
Modules are the fundamental building blocks of the system, as they allow to
register functionality with the system as part of the implementation of the
Module trait. As such, Module::setup must be allowed to return
any kind of error, which is then converted into a module error.
The enum is deliberately not marked as non-exhaustive, because this type is
intended to be the sink for all errors that typically occur in modules, and
should never be used in external code. As such, we’re allowed to freely add
new variants, moving errors out of Error::Other when necessary.
In order to integrate with error types that are not already covered by the
existing variants, the IntoError conversion trait is provided. Please
note that this trait should only be used sparingly, and could denote a code
smell, since Module::setup implementations should rarely be fallible
besides identifier and expression parsing errors, especially not involving
side effects like file system or network access. Implementations should only
fail due to programmer or configuration errors, which should be covered by
the existing variants. In case you think an essential variant is missing,
please report it on our issue tracker.
Variants§
Id(Error)
Identifier error.
Expression(Error)
Expression error.
Other(Box<dyn Error + Send + 'static>)
Catch-all errors.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<E> IntoError for E
impl<E> IntoError for E
Source§fn into_error(self) -> Error
fn into_error(self) -> Error
Converts any error into a module error.
This implementation attempts to downcast the error into one of the known
variants, and falls back to the catch-all variant in all other cases. It
also ensures that the error is not double-boxed, returning all unknown
errors captured by the Error::Other variant unchanged.
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<K, V> TryAsStorage<K> for V
impl<K, V> TryAsStorage<K> for V
Source§fn try_as_storage(
item: &(dyn Any + 'static),
) -> Result<<V as TryAsStorage<K>>::Target<'_>, Error>
fn try_as_storage( item: &(dyn Any + 'static), ) -> Result<<V as TryAsStorage<K>>::Target<'_>, Error>
Attempts to convert into a storage reference.
§Errors
The following errors might be returned:
Error::Downcast: Item cannot be downcast.
§Examples
use std::any::Any;
use zrx_storage::convert::TryAsStorage;
use zrx_storage::Storage;
// Create storage and initial state
let mut storage = Storage::default();
storage.insert("key", 42);
// Obtain type-erased reference
let item: &dyn Any = &storage;
// Obtain storage reference
let storage = <i32>::try_as_storage(item)?;Source§impl<K, V> TryAsStorageMut<K> for V
impl<K, V> TryAsStorageMut<K> for V
Source§fn try_as_storage_mut(
item: &mut (dyn Any + 'static),
) -> Result<<V as TryAsStorageMut<K>>::Target<'_>, Error>
fn try_as_storage_mut( item: &mut (dyn Any + 'static), ) -> Result<<V as TryAsStorageMut<K>>::Target<'_>, Error>
Attempts to convert into a mutable storage reference.
§Errors
The following errors might be returned:
Error::Downcast: Item cannot be downcast.
§Examples
use std::any::Any;
use zrx_storage::convert::TryAsStorageMut;
use zrx_storage::Storage;
// Create storage and initial state
let mut storage = Storage::default();
storage.insert("key", 42);
// Obtain mutable type-erased reference
let item: &mut dyn Any = &mut storage;
// Obtain mutable storage reference
let storage = <i32>::try_as_storage_mut(item)?;