1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/// Represents the type of error that occurred while parsing.
#[derive(Debug, PartialEq, Eq)]
pub enum Error {
/// Unexpected EOF while parsing.
Eof,
/// Expected colon while parsing object.
ExpectedColon,
/// Expected value but found EOF instead.
ExpectedValue,
/// Unexpected token while parsing.
UnexpectedToken,
/// String wasn't properly terminated.
UnclosedString,
/// Found raw control characters inside string while parsing.
ControlCharacter,
/// Invalid escape sequence in string.
InvalidEscapeSequnce,
/// Invalid JSON literal.
InvalidLiteral,
/// Comma after the last element of an array or an object.
TrailingComma,
/// Number starting with a decimal point.
LeadingDecimal,
/// Number ending with a decimal point.
TrailingDecimal,
/// Number starting with zero.
LeadingZero,
/// Number is bigger than it can represent.
NumberOverflow,
}
impl crate::value::builder::ErrorBuilder for Error {
#[inline]
fn eof() -> Self {
Self::Eof
}
#[inline]
fn expected_colon() -> Self {
Self::ExpectedColon
}
#[inline]
fn expected_value() -> Self {
Self::ExpectedValue
}
#[inline]
fn trailing_comma() -> Self {
Self::TrailingComma
}
#[inline]
fn unclosed_string() -> Self {
Self::UnclosedString
}
#[inline]
fn invalid_escape() -> Self {
Self::InvalidEscapeSequnce
}
#[inline]
fn control_character() -> Self {
Self::ControlCharacter
}
#[inline]
fn invalid_literal() -> Self {
Self::InvalidLiteral
}
#[inline]
fn trailing_decimal() -> Self {
Self::TrailingDecimal
}
#[inline]
fn leading_decimal() -> Self {
Self::LeadingDecimal
}
#[inline]
fn leading_zero() -> Self {
Self::LeadingZero
}
#[inline]
fn number_overflow() -> Self {
Self::NumberOverflow
}
#[inline]
fn unexpected_token() -> Self {
Self::UnexpectedToken
}
#[inline]
fn apply_span(&mut self, _: usize, _: usize) {}
}