Enum serde::de::Unexpected

source ·
pub enum Unexpected<'a> {
Show 18 variants Bool(bool), Unsigned(u64), Signed(i64), Float(f64), Char(char), Str(&'a str), Bytes(&'a [u8]), Unit, Option, NewtypeStruct, Seq, Map, Enum, UnitVariant, NewtypeVariant, TupleVariant, StructVariant, Other(&'a str),
}
Expand description

Unexpected represents an unexpected invocation of any one of the Visitor trait methods.

This is used as an argument to the invalid_type, invalid_value, and invalid_length methods of the Error trait to build error messages.

fn visit_bool<E>(self, v: bool) -> Result<Self::Value, E>
where
    E: de::Error,
{
    Err(de::Error::invalid_type(Unexpected::Bool(v), &self))
}

Variants§

§

Bool(bool)

The input contained a boolean value that was not expected.

§

Unsigned(u64)

The input contained an unsigned integer u8, u16, u32 or u64 that was not expected.

§

Signed(i64)

The input contained a signed integer i8, i16, i32 or i64 that was not expected.

§

Float(f64)

The input contained a floating point f32 or f64 that was not expected.

§

Char(char)

The input contained a char that was not expected.

§

Str(&'a str)

The input contained a &str or String that was not expected.

§

Bytes(&'a [u8])

The input contained a &[u8] or Vec<u8> that was not expected.

§

Unit

The input contained a unit () that was not expected.

§

Option

The input contained an Option<T> that was not expected.

§

NewtypeStruct

The input contained a newtype struct that was not expected.

§

Seq

The input contained a sequence that was not expected.

§

Map

The input contained a map that was not expected.

§

Enum

The input contained an enum that was not expected.

§

UnitVariant

The input contained a unit variant that was not expected.

§

NewtypeVariant

The input contained a newtype variant that was not expected.

§

TupleVariant

The input contained a tuple variant that was not expected.

§

StructVariant

The input contained a struct variant that was not expected.

§

Other(&'a str)

A message stating what uncategorized thing the input contained that was not expected.

The message should be a noun or noun phrase, not capitalized and without a period. An example message is “unoriginal superhero”.

Trait Implementations§

source§

impl<'a> Clone for Unexpected<'a>

source§

fn clone(&self) -> Unexpected<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for Unexpected<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> Display for Unexpected<'a>

source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> PartialEq for Unexpected<'a>

source§

fn eq(&self, other: &Unexpected<'a>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> Copy for Unexpected<'a>

source§

impl<'a> StructuralPartialEq for Unexpected<'a>

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for Unexpected<'a>

§

impl<'a> Send for Unexpected<'a>

§

impl<'a> Sync for Unexpected<'a>

§

impl<'a> Unpin for Unexpected<'a>

§

impl<'a> UnwindSafe for Unexpected<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.