pub struct Error(/* private fields */);Expand description
Wrapper type for handling different Vouched error types uniformly.
This allows code that works with multiple Vouched wrappers to handle their
validation errors through a single type. It supports automatic conversion
through the ? operator.
Available with the alloc feature, which is enabled by the default std
feature.
§Examples
// Function that handles different Vouched error types uniformly.
fn process_errors() -> Result<(), Error> {
// Any error implementing VouchedError can be converted into Error.
let err = UserIdError::TooShort(TooShortError::new(1, 0));
Err(Error::from(err))
}
// Inspect the concrete validation error kind.
let result = process_errors();
assert!(result.is_err());
let err = result.unwrap_err();
assert!(err.as_too_short().is_some());Implementations§
Source§impl Error
impl Error
Sourcepub fn new(inner: Box<dyn VouchedError>) -> Error
pub fn new(inner: Box<dyn VouchedError>) -> Error
Wraps a boxed generated Vouched error.
Sourcepub fn into_inner(self) -> Box<dyn VouchedError>
pub fn into_inner(self) -> Box<dyn VouchedError>
Returns the wrapped generated Vouched error.
Trait Implementations§
Source§impl AsRef<dyn VouchedError> for Error
Available on crate feature alloc only.
impl AsRef<dyn VouchedError> for Error
Available on crate feature
alloc only.Source§fn as_ref(&self) -> &(dyn VouchedError + 'static)
fn as_ref(&self) -> &(dyn VouchedError + 'static)
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl Error for Error
Available on crate feature alloc only.
impl Error for Error
Available on crate feature
alloc only.Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl<E> From<E> for Errorwhere
E: VouchedError,
Available on crate feature alloc only.
impl<E> From<E> for Errorwhere
E: VouchedError,
Available on crate feature
alloc only.Source§impl Structable for Error
Available on crate feature valuable only.
impl Structable for Error
Available on crate feature
valuable only.Source§fn definition(&self) -> StructDef<'_>
fn definition(&self) -> StructDef<'_>
Returns the struct’s definition. Read more
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
Mutably borrows from an owned value. Read more