#[non_exhaustive]pub enum DecodeErrorKind {
Syntax(ErrorKind),
WrongType {
expected: &'static str,
found: Kind,
},
OutOfRange {
expected: &'static str,
},
StringNotBorrowable,
WrongLength {
expected: usize,
found: usize,
},
MissingField(&'static str),
UnknownField,
DuplicateField,
InvalidValue(&'static str),
Custom(Cow<'static, str>),
}Expand description
What went wrong reading a typed value; see DecodeError.
The enum is #[non_exhaustive]: match with a wildcard arm.
§Examples
use jsonx_lib::{DecodeErrorKind, Kind};
let err = jsonx_lib::from_str::<u8>("\"7\"").unwrap_err();
assert_eq!(err.kind(), &DecodeErrorKind::WrongType { expected: "u8", found: Kind::String });Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Syntax(ErrorKind)
The text is not valid JSON, or is over a budget: the ErrorKind a
parse of the same text reports.
WrongType
The value is of the wrong kind: found where expected (a type
name such as "u32", or a description such as "an object")
belongs.
OutOfRange
A number that does not fit the target type: out of its range, or not
an integer for an integer type (1.5 or 1e3 for a u32; integers
are read from integer text only, as Number::as_i64 does).
StringNotBorrowable
A string with escape sequences was read into a borrowed &str, which
can only point into the input. Read it into String or Cow<str>.
WrongLength
An array of the wrong length for a fixed-size array or a tuple.
MissingField(&'static str)
An object lacks a member its type requires. The offset is the object’s opening brace.
UnknownField
An object has a member its type does not know, refused with
ObjectReader::unknown_field. The key is the last path segment.
DuplicateField
An object repeats a member, found by ObjectReader::field or a map
under DuplicateKeys::Error. The key is the last path segment.
InvalidValue(&'static str)
The value has the right kind but not an acceptable value; the text
says what was expected ("a single character", "a URI").
Custom(Cow<'static, str>)
An error of the implementation’s own, with its message.