pub struct Error(/* private fields */);Expand description
Type-erased error wrapper for when you don’t need to preserve the concrete type.
This is a newtype wrapper around Box<dyn StdError> that enables proper trait
resolution for typed catches. It does NOT implement Error itself (to avoid
trait impl conflicts), but provides access to the inner error.
Implementations§
Source§impl Error
impl Error
Sourcepub fn from_box(e: Box<dyn StdError + Send + Sync + 'static>) -> Self
pub fn from_box(e: Box<dyn StdError + Send + Sync + 'static>) -> Self
Create from a boxed error.
Sourcepub fn as_error(&self) -> &(dyn StdError + Send + Sync + 'static)
pub fn as_error(&self) -> &(dyn StdError + Send + Sync + 'static)
Get the inner error as a trait object reference.
Sourcepub fn as_dyn_error(&self) -> &(dyn StdError + 'static)
pub fn as_dyn_error(&self) -> &(dyn StdError + 'static)
Get the inner error as a trait object reference (non-Send/Sync for Error trait compat).
Sourcepub fn downcast_ref<T: StdError + 'static>(&self) -> Option<&T>
pub fn downcast_ref<T: StdError + 'static>(&self) -> Option<&T>
Try to downcast to a specific error type.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin 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