pub struct JsonSyntaxError { /* private fields */ }Expand description
A JSON syntax error with byte and human-readable source coordinates.
§Examples
use qubit_json::decode::{JsonSyntaxError, JsonSyntaxErrorReason};
let error = JsonSyntaxError::new(0, 1, 1,
JsonSyntaxErrorReason::UnexpectedEnd); assert_eq!(error.line(), 1);
assert_eq!(error.reason(), JsonSyntaxErrorReason::UnexpectedEnd);Implementations§
Source§impl JsonSyntaxError
impl JsonSyntaxError
Sourcepub const fn new(
offset: usize,
line: usize,
column: usize,
reason: JsonSyntaxErrorReason,
) -> Self
pub const fn new( offset: usize, line: usize, column: usize, reason: JsonSyntaxErrorReason, ) -> Self
Creates a syntax error from a source position and stable reason.
§Parameters
offset- Zero-based byte offset at which the error was observed.line- One-based source line containing the error.column- One-based UTF-8 character column containing the error.reason- Stable classification of the lexical failure.
§Returns
A syntax error containing the supplied location and classification.
Sourcepub const fn offset(&self) -> usize
pub const fn offset(&self) -> usize
Returns the zero-based byte offset.
§Returns
The zero-based byte offset at which the error was observed.
Sourcepub const fn column(&self) -> usize
pub const fn column(&self) -> usize
Returns the one-based UTF-8 character column.
§Returns
The one-based UTF-8 character column containing the error.
Sourcepub const fn reason(&self) -> JsonSyntaxErrorReason
pub const fn reason(&self) -> JsonSyntaxErrorReason
Trait Implementations§
Source§impl Clone for JsonSyntaxError
impl Clone for JsonSyntaxError
Source§fn clone(&self) -> JsonSyntaxError
fn clone(&self) -> JsonSyntaxError
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for JsonSyntaxError
Source§impl Debug for JsonSyntaxError
impl Debug for JsonSyntaxError
Source§impl Display for JsonSyntaxError
impl Display for JsonSyntaxError
impl Eq for JsonSyntaxError
Source§impl Error for JsonSyntaxError
impl Error for JsonSyntaxError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns 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 PartialEq for JsonSyntaxError
impl PartialEq for JsonSyntaxError
impl StructuralPartialEq for JsonSyntaxError
Auto Trait Implementations§
impl Freeze for JsonSyntaxError
impl RefUnwindSafe for JsonSyntaxError
impl Send for JsonSyntaxError
impl Sync for JsonSyntaxError
impl Unpin for JsonSyntaxError
impl UnsafeUnpin for JsonSyntaxError
impl UnwindSafe for JsonSyntaxError
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