Struct tinyjson::UnexpectedValue
source · pub struct UnexpectedValue { /* private fields */ }
Expand description
Error caused when trying to convert JsonValue
into some wrong type value.
use tinyjson::{JsonValue, UnexpectedValue};
use std::convert::TryFrom;
let error = String::try_from(JsonValue::from(1.0)).unwrap_err();
assert!(matches!(error, UnexpectedValue{..}));
Implementations§
Trait Implementations§
source§impl Debug for UnexpectedValue
impl Debug for UnexpectedValue
source§impl Display for UnexpectedValue
impl Display for UnexpectedValue
source§impl Error for UnexpectedValue
impl Error for UnexpectedValue
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
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 From<UnexpectedValue> for JsonValue
impl From<UnexpectedValue> for JsonValue
Convert this error into the value which failed to be converted.
use tinyjson::JsonValue;
use std::convert::TryFrom;
let error = String::try_from(JsonValue::from(1.0)).unwrap_err();
assert_eq!(JsonValue::from(error), JsonValue::Number(1.0));
source§fn from(err: UnexpectedValue) -> Self
fn from(err: UnexpectedValue) -> Self
Converts to this type from the input type.