#[non_exhaustive]pub struct DecodeError { /* private fields */ }Expand description
A JSON document could not be decoded into the expected type.
The error deliberately carries no part of the input. A decoded document may
contain application state and therefore personal data, and both the codec’s
own error text and serde’s type-mismatch messages quote the input. What
is kept is the kind, the position and the field path, which are derived
from the expected type rather than from the values.
Implementations§
Source§impl DecodeError
impl DecodeError
Sourcepub fn kind(&self) -> DecodeErrorKind
pub fn kind(&self) -> DecodeErrorKind
Which of the three failure classes this is.
Sourcepub fn line(&self) -> usize
pub fn line(&self) -> usize
The one-based line the parser stopped at, or 0 when the document was rejected before it was parsed.
Sourcepub fn column(&self) -> usize
pub fn column(&self) -> usize
The one-based column the parser stopped at, or 0 when the document was rejected before it was parsed.
Sourcepub fn path(&self) -> &str
pub fn path(&self) -> &str
The path of the offending field, with dotted names and bracketed
indices, for example answers.tone.confidence or models[1].name.
The path of the document root is ., and it is empty when the failure
carries no path at all.
A name in the path may be an object key the input chose, so it is
rendered safe to print: a control character or a format character that
reorders or hides text is written as a Rust escape (\n, \u{1b},
\u{202e}), a backslash is written \\ so that an escape cannot be
mistaken for text, and other printable text, non-ASCII included, is kept
as it is.
Each name is cut at 128 characters and the whole path at 320, counted
after escaping, and a cut is marked with U+2026.
Trait Implementations§
Source§impl Clone for DecodeError
impl Clone for DecodeError
Source§impl Debug for DecodeError
impl Debug for DecodeError
Source§impl Display for DecodeError
impl Display for DecodeError
impl Eq for DecodeError
Source§impl Error for DecodeError
impl Error for DecodeError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<DecodeError> for ContentError
impl From<DecodeError> for ContentError
Source§fn from(source: DecodeError) -> Self
fn from(source: DecodeError) -> Self
Source§impl PartialEq for DecodeError
impl PartialEq for DecodeError
impl StructuralPartialEq for DecodeError
Auto Trait Implementations§
impl Freeze for DecodeError
impl RefUnwindSafe for DecodeError
impl Send for DecodeError
impl Sync for DecodeError
impl Unpin for DecodeError
impl UnsafeUnpin for DecodeError
impl UnwindSafe for DecodeError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more