pub struct ConversionError {
pub original: MsgPack,
pub attempted: &'static str,
}
Expand description
An error that occurred when trying to access a field as a different type
The “as_type” functions of MsgPack can throw this error. It contains the original object and a string representation of the attempted conversion.
Fields§
§original: MsgPack
The original object, owned.
attempted: &'static str
A string that contains which type conversion was attempted.
Implementations§
Source§impl ConversionError
impl ConversionError
Sourcepub fn recover(self) -> MsgPack
pub fn recover(self) -> MsgPack
Recovers the MsgPack object from the error
use msgpack_simple::MsgPack;
let float = MsgPack::Float(42.0);
let error = float.as_int().unwrap_err(); // trigger and capture an error
let recovered = error.recover();
assert!(recovered.is_float());
assert_eq!(recovered.as_float().unwrap(), 42.0);
Trait Implementations§
Source§impl Debug for ConversionError
impl Debug for ConversionError
Source§impl Display for ConversionError
impl Display for ConversionError
Source§impl Error for ConversionError
impl Error for ConversionError
1.30.0 · 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()
Auto Trait Implementations§
impl Freeze for ConversionError
impl RefUnwindSafe for ConversionError
impl Send for ConversionError
impl Sync for ConversionError
impl Unpin for ConversionError
impl UnwindSafe for ConversionError
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