Enum Unexpected

enum Unexpected<'a>

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.

# use std::fmt;
#
# use serde::de::{self, Unexpected, Visitor};
#
# struct Example;
#
# impl<'de> Visitor<'de> for Example {
#     type Value = ();
#
#     fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
#         write!(formatter, "definitely not a boolean")
#     }
#
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".

Implementations

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

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

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

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

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

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

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

impl<'a> Freeze for Unexpected<'a>

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

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

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

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

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

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

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

impl<'a> UnsafeUnpin for Unexpected<'a>

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

impl<T> Any for Unexpected<'a>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Unexpected<'a>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Unexpected<'a>

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

impl<T> CloneToUninit for Unexpected<'a>

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for Unexpected<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Unexpected<'a>

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T> ToString for Unexpected<'a>

fn to_string(self: &Self) -> String

impl<T, U> Into for Unexpected<'a>

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for Unexpected<'a>

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

impl<T, U> TryInto for Unexpected<'a>

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