pub struct Error {
pub err: ErrorType,
pub index_end: usize,
pub index_start: usize,
}Expand description
Error type of validation functions.
Fields§
§err: ErrorTypeThe ErrorType variant that describes the current error.
index_end: usizeThe zero-based index before which the error ends. The character at this index will not be included.
index_start: usizeThe zero-based index at which the error begins.
Implementations§
Source§impl Error
impl Error
Sourcepub fn new(err: ErrorType, index_start: usize, index_end: usize) -> Error
pub fn new(err: ErrorType, index_start: usize, index_end: usize) -> Error
Construct a new error in the specified range.
Sourcepub fn serialize(&self) -> String
pub fn serialize(&self) -> String
Serialize the error into a JSON value.
Examples
// Invalid `true` root value in JSON document.
let text: &str = "trua";
let errors = jsonprima::validate(&text);
let serialized: String = errors.get(0).unwrap().serialize();
assert_eq!(serialized, "{\"code\": \"E105\", \"description\": \"Invalid character in literal name.\", \"index_end\": 4, \"index_start\": 0}");Trait Implementations§
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnwindSafe for Error
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