JsonErrorKind

Enum JsonErrorKind 

Source
pub enum JsonErrorKind {
Show 14 variants Scan(ScanErrorKind), ScanWithContext { error: ScanErrorKind, expected_type: &'static str, }, UnexpectedToken { got: String, expected: &'static str, }, UnexpectedEof { expected: &'static str, }, TypeMismatch { expected: &'static str, got: &'static str, }, UnknownField { field: String, expected: Vec<&'static str>, suggestion: Option<&'static str>, }, MissingField { field: &'static str, object_start: Option<Span>, object_end: Option<Span>, }, InvalidValue { message: String, }, Reflect(ReflectError), NumberOutOfRange { value: String, target_type: &'static str, }, DuplicateKey { key: String, }, InvalidUtf8, Solver(String), Io(String),
}
Expand description

Specific error kinds for JSON deserialization

Variants§

§

Scan(ScanErrorKind)

Scanner/adapter error

§

ScanWithContext

Scanner error with type context (what type was being parsed)

Fields

§error: ScanErrorKind

The underlying scan error

§expected_type: &'static str

The type that was being parsed

§

UnexpectedToken

Unexpected token

Fields

§got: String

The token that was found

§expected: &'static str

What was expected instead

§

UnexpectedEof

Unexpected end of input

Fields

§expected: &'static str

What was expected before EOF

§

TypeMismatch

Type mismatch

Fields

§expected: &'static str

The expected type

§got: &'static str

The actual type found

§

UnknownField

Unknown field in struct

Fields

§field: String

The unknown field name

§expected: Vec<&'static str>

List of valid field names

§suggestion: Option<&'static str>

Suggested field name (if similar to an expected field)

§

MissingField

Missing required field

Fields

§field: &'static str

The name of the missing field

§object_start: Option<Span>

Span of the object start (opening brace)

§object_end: Option<Span>

Span of the object end (closing brace)

§

InvalidValue

Invalid value for type

Fields

§message: String

Description of why the value is invalid

§

Reflect(ReflectError)

Reflection error from facet-reflect

§

NumberOutOfRange

Number out of range

Fields

§value: String

The numeric value that was out of range

§target_type: &'static str

The target type that couldn’t hold the value

§

DuplicateKey

Duplicate key in object

Fields

§key: String

The key that appeared more than once

§

InvalidUtf8

Invalid UTF-8 in string

§

Solver(String)

Solver error (for flattened types)

§

Io(String)

I/O error (for streaming deserialization)

Implementations§

Source§

impl JsonErrorKind

Source

pub fn code(&self) -> &'static str

Get an error code for this kind of error.

Source

pub fn label(&self) -> String

Get a label describing where/what the error points to.

Trait Implementations§

Source§

impl Debug for JsonErrorKind

Source§

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

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

impl Display for JsonErrorKind

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

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

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.