pub struct Error<DelegateError = Infallible> { /* private fields */ }
Expand description
A JSON parsing error with location information.
Implementations§
source§impl<DelegateError> Error<DelegateError>
impl<DelegateError> Error<DelegateError>
sourcepub const fn kind(&self) -> &ErrorKind<DelegateError>
pub const fn kind(&self) -> &ErrorKind<DelegateError>
Returns the kind of the error.
Examples found in repository?
examples/heapless.rs (line 16)
4 5 6 7 8 9 10 11 12 13 14 15 16 17
fn main() {
// Using a heapless vec, we can parse directly to the stack.
let doc: HeaplessDocument<'_, 3> =
HeaplessDocument::from_json(r#"{"hello": "world"}"#).expect("invalid json");
let mut nodes = doc.into_iter();
assert_eq!(nodes.next(), Some(Node::Object { length: 1 }));
assert_eq!(nodes.next(), Some(Node::String(JsonString::from("hello"))));
assert_eq!(nodes.next(), Some(Node::String(JsonString::from("world"))));
// When parsing a document too large for the heapless Vec, an error will be
// returned instead of panicing.
let error = HeaplessDocument::<3>::from_json("[1, 2, 3, 4]").expect_err("shouldn't have space");
assert_eq!(error.kind(), &ErrorKind::PaylodTooLarge);
}
Trait Implementations§
source§impl<DelegateError> Error for Error<DelegateError>
Available on crate feature std
only.
impl<DelegateError> Error for Error<DelegateError>
Available on crate feature
std
only.1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
source§impl<DelegateError: PartialEq> PartialEq for Error<DelegateError>
impl<DelegateError: PartialEq> PartialEq for Error<DelegateError>
impl<DelegateError> StructuralPartialEq for Error<DelegateError>
Auto Trait Implementations§
impl<DelegateError> RefUnwindSafe for Error<DelegateError>where
DelegateError: RefUnwindSafe,
impl<DelegateError> Send for Error<DelegateError>where
DelegateError: Send,
impl<DelegateError> Sync for Error<DelegateError>where
DelegateError: Sync,
impl<DelegateError> Unpin for Error<DelegateError>where
DelegateError: Unpin,
impl<DelegateError> UnwindSafe for Error<DelegateError>where
DelegateError: UnwindSafe,
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
Mutably borrows from an owned value. Read more