[][src]Struct jsonprima::Error

pub struct Error {
    pub err: ErrorType,
    pub index_end: usize,
    pub index_start: usize,
}

Error type of validation functions.

Fields

err: ErrorType

The ErrorType variant that describes the current error.

index_end: usize

The zero-based index before which the error ends. The character at this index will not be included.

index_start: usize

The zero-based index at which the error begins.

Methods

impl Error[src]

pub fn new(err: ErrorType, index_start: usize, index_end: usize) -> Error[src]

Construct a new error in the specified range.

pub fn serialize(&self) -> String[src]

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

impl Debug for Error[src]

Auto Trait Implementations

impl Unpin for Error

impl Sync for Error

impl Send for Error

impl UnwindSafe for Error

impl RefUnwindSafe for Error

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]