Enum ErrorType

Source
pub enum ErrorType {
Show 41 variants E100, E101, E103, E104, E105, E106, E107, E108, E109, E110, E111, E112, E113, E114, E116, E117, E118, E119, E122, E123, E124, E125, E126, E127, E128, E129, E130, E131, E132, E133, E134, E135, E136, E137, E138, E139, E140, E141, E142, E143, E144,
}
Expand description

A list of all error variants used by this module.

Variants§

§

E100

Empty JSON document.

§

E101

Raw use of control characters in JSON string.

§

E103

Illegal character “t” after structural token. Expected comma or colon.

§

E104

No more graphemes to parse.

§

E105

Invalid character in literal name.

§

E106

Invalid literal.

§

E107

Illegal character “f” after structural token. Expected comma or colon.

§

E108

Illegal character “n” after structural token. Expected comma or colon.

§

E109

Illegal number after structural token. Expected comma or colon.

§

E110

Illegal non ASCII decimal digit character in number.

§

E111

Numbers cannot contain leading zeros.

§

E112

Could not parse out of range JSON number.

§

E113

Could not parse JSON number.

§

E114

Illegal string after structural token. Expected comma or colon.

§

E116

§

E117

§

E118

Invalid Unicode grapheme in JSON string.

§

E119

Invalid Unicode escape sequence in second surrogate pair.

§

E122

Unexpected comma at the start of JSON document.

§

E123

Unexpected comma after structural token.

§

E124

Invalid use of comma after document root value.

§

E125

Illegal begin-array after JSON value.

§

E126

Illegal end-array. No begin-array match.

§

E127

Unterminated array.

§

E128

Unterminated object.

§

E129

Illegal end-array after comma.

§

E130

Illegal begin-object after JSON value.

§

E131

Illegal end-object. No begin-object match.

§

E132

Illegal end-object after comma.

§

E133

Illegal end-array after colon.

§

E134

Illegal end-object after colon.

§

E135

Invalid object member. Member value does not exist.

§

E136

Invalid use of colon.

§

E137

Invalid use of number as object name.

§

E138

§

E139

Invalid use of false as object name.

§

E140

§

E141

Invalid object member

§

E142

Invalid use of array as object name.

§

E143

Invalid use of object as object name.

§

E144

Duplicate object name.

Implementations§

Source§

impl ErrorType

Used to represent the various error variants in this module.

Source

pub fn description(&self) -> &str

Return the error description.

Examples

assert_eq!(jsonprima::ErrorType::E104.description(), "No more graphemes to parse.");
// Invalid `true` root value in JSON document.
let text: &str = "trua";
let errors = jsonprima::validate(&text);
let description = errors.get(0).unwrap().err.description();
assert_eq!(description, "Invalid character in literal name.");
Source

pub fn code(&self) -> &str

Return the error code.

Examples

assert_eq!(jsonprima::ErrorType::E104.code(), "E104");
// Invalid `true` root value in JSON document.
let text: &str = "trua";
let errors = jsonprima::validate(&text);
let code = errors.get(0).unwrap().err.code();
assert_eq!(code, "E105");

Trait Implementations§

Source§

impl Debug for ErrorType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.