pub struct ParseContext<E> {
pub error: E,
pub offset: usize,
pub field: Option<&'static str>,
}Expand description
Diagnostic context for a parse failure.
Carries the byte offset within the input where the parser stopped,
alongside an error variant. Most parser entry points return the
bare error type for backwards compatibility; use
ParseContext::with_error to wrap one when richer diagnostics are
useful (e.g. when reporting failures from a fuzz harness or when
logging untrusted wire data).
Fields§
§error: EUnderlying error.
offset: usizeByte offset within the input where the parser noticed the problem (0 if unknown).
field: Option<&'static str>Optional human-readable name for the field that failed.
Implementations§
Source§impl<E> ParseContext<E>
impl<E> ParseContext<E>
Sourcepub const fn with_error(
error: E,
offset: usize,
field: Option<&'static str>,
) -> Self
pub const fn with_error( error: E, offset: usize, field: Option<&'static str>, ) -> Self
Wrap an error with the given byte offset and optional field name.
Trait Implementations§
Source§impl<E: Clone> Clone for ParseContext<E>
impl<E: Clone> Clone for ParseContext<E>
Source§fn clone(&self) -> ParseContext<E>
fn clone(&self) -> ParseContext<E>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<E: Debug> Debug for ParseContext<E>
impl<E: Debug> Debug for ParseContext<E>
Source§impl<E: Display> Display for ParseContext<E>
impl<E: Display> Display for ParseContext<E>
Source§impl<E: PartialEq> PartialEq for ParseContext<E>
impl<E: PartialEq> PartialEq for ParseContext<E>
impl<E: Eq> Eq for ParseContext<E>
impl<E> StructuralPartialEq for ParseContext<E>
Auto Trait Implementations§
impl<E> Freeze for ParseContext<E>where
E: Freeze,
impl<E> RefUnwindSafe for ParseContext<E>where
E: RefUnwindSafe,
impl<E> Send for ParseContext<E>where
E: Send,
impl<E> Sync for ParseContext<E>where
E: Sync,
impl<E> Unpin for ParseContext<E>where
E: Unpin,
impl<E> UnwindSafe for ParseContext<E>where
E: 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