[][src]Struct msgpack_simple::ConversionError

pub struct ConversionError {
    pub original: MsgPack,
    pub attempted: &'static str,
}

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

impl ConversionError[src]

pub fn recover(self) -> MsgPack[src]

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

impl Debug for ConversionError[src]

impl Display for ConversionError[src]

impl Error for ConversionError[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.