Trait binrw::error::CustomError
source · pub trait CustomError:
Display
+ Debug
+ Send
+ Sync
+ Sealed { }
Expand description
The CustomError
trait describes types that are usable as custom errors
in a BinResult
.
This trait is automatically implemented for any type which implements the
same traits as std::error::Error
, so anything you would normally use as
an error in other code is also a valid CustomError
, with the additional
restriction that it must also be Send
+ Sync
.
This trait is Sealed.
Implementations§
source§impl dyn CustomError
impl dyn CustomError
sourcepub fn downcast<T: CustomError + 'static>(
self: Box<Self>,
) -> Result<Box<T>, Box<Self>>
pub fn downcast<T: CustomError + 'static>( self: Box<Self>, ) -> Result<Box<T>, Box<Self>>
Attempts to downcast a boxed error to a concrete type.
§Errors
If the downcast fails, Self
will be returned.
sourcepub fn downcast_mut<T: CustomError + 'static>(&mut self) -> Option<&mut T>
pub fn downcast_mut<T: CustomError + 'static>(&mut self) -> Option<&mut T>
Returns some mutable reference to the boxed value if it is of type T
, or
None
if it isn’t.
sourcepub fn downcast_ref<T: CustomError + 'static>(&self) -> Option<&T>
pub fn downcast_ref<T: CustomError + 'static>(&self) -> Option<&T>
Returns some reference to the boxed value if it is of type T
, or
None
if it isn’t.
sourcepub fn is<T: CustomError + 'static>(&self) -> bool
pub fn is<T: CustomError + 'static>(&self) -> bool
Returns true
if the boxed type is the same as T
.