mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-24 01:48:00 +00:00
Remove "_error" from de::Error::*_error
This commit is contained in:
@@ -152,35 +152,35 @@ impl From<de::value::Error> for Error {
|
||||
fn from(error: de::value::Error) -> Error {
|
||||
match error {
|
||||
de::value::Error::SyntaxError => {
|
||||
de::Error::syntax_error()
|
||||
de::Error::syntax()
|
||||
}
|
||||
de::value::Error::EndOfStreamError => {
|
||||
de::Error::end_of_stream_error()
|
||||
de::Error::end_of_stream()
|
||||
}
|
||||
de::value::Error::UnknownFieldError(field) => {
|
||||
Error::SyntaxError(ErrorCode::UnknownField(field), 0, 0)
|
||||
}
|
||||
de::value::Error::MissingFieldError(field) => {
|
||||
de::Error::missing_field_error(field)
|
||||
de::Error::missing_field(field)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl de::Error for Error {
|
||||
fn syntax_error() -> Error {
|
||||
fn syntax() -> Error {
|
||||
Error::SyntaxError(ErrorCode::ExpectedSomeValue, 0, 0)
|
||||
}
|
||||
|
||||
fn end_of_stream_error() -> Error {
|
||||
fn end_of_stream() -> Error {
|
||||
Error::SyntaxError(ErrorCode::EOFWhileParsingValue, 0, 0)
|
||||
}
|
||||
|
||||
fn unknown_field_error(field: &str) -> Error {
|
||||
fn unknown_field(field: &str) -> Error {
|
||||
Error::SyntaxError(ErrorCode::UnknownField(field.to_string()), 0, 0)
|
||||
}
|
||||
|
||||
fn missing_field_error(field: &'static str) -> Error {
|
||||
fn missing_field(field: &'static str) -> Error {
|
||||
Error::MissingFieldError(field)
|
||||
}
|
||||
}
|
||||
|
||||
+10
-10
@@ -650,7 +650,7 @@ impl de::Deserializer for Deserializer {
|
||||
{
|
||||
let value = match self.value.take() {
|
||||
Some(value) => value,
|
||||
None => { return Err(de::Error::end_of_stream_error()); }
|
||||
None => { return Err(de::Error::end_of_stream()); }
|
||||
};
|
||||
|
||||
match value {
|
||||
@@ -687,7 +687,7 @@ impl de::Deserializer for Deserializer {
|
||||
match self.value {
|
||||
Some(Value::Null) => visitor.visit_none(),
|
||||
Some(_) => visitor.visit_some(self),
|
||||
None => Err(de::Error::end_of_stream_error()),
|
||||
None => Err(de::Error::end_of_stream()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -700,20 +700,20 @@ impl de::Deserializer for Deserializer {
|
||||
{
|
||||
let value = match self.value.take() {
|
||||
Some(Value::Object(value)) => value,
|
||||
Some(_) => { return Err(de::Error::syntax_error()); }
|
||||
None => { return Err(de::Error::end_of_stream_error()); }
|
||||
Some(_) => { return Err(de::Error::syntax()); }
|
||||
None => { return Err(de::Error::end_of_stream()); }
|
||||
};
|
||||
|
||||
let mut iter = value.into_iter();
|
||||
|
||||
let (variant, value) = match iter.next() {
|
||||
Some(v) => v,
|
||||
None => return Err(de::Error::syntax_error()),
|
||||
None => return Err(de::Error::syntax()),
|
||||
};
|
||||
|
||||
// enums are encoded in json as maps with a single key:value pair
|
||||
match iter.next() {
|
||||
Some(_) => Err(de::Error::syntax_error()),
|
||||
Some(_) => Err(de::Error::syntax()),
|
||||
None => visitor.visit(VariantDeserializer {
|
||||
de: self,
|
||||
val: Some(value),
|
||||
@@ -768,7 +768,7 @@ impl<'a> de::VariantVisitor for VariantDeserializer<'a> {
|
||||
visitor,
|
||||
)
|
||||
} else {
|
||||
Err(de::Error::syntax_error())
|
||||
Err(de::Error::syntax())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -788,7 +788,7 @@ impl<'a> de::VariantVisitor for VariantDeserializer<'a> {
|
||||
visitor,
|
||||
)
|
||||
} else {
|
||||
Err(de::Error::syntax_error())
|
||||
Err(de::Error::syntax())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -834,7 +834,7 @@ impl<'a> de::SeqVisitor for SeqDeserializer<'a> {
|
||||
if self.len == 0 {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(de::Error::end_of_stream_error())
|
||||
Err(de::Error::end_of_stream())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -879,7 +879,7 @@ impl<'a> de::MapVisitor for MapDeserializer<'a> {
|
||||
if self.len == 0 {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(de::Error::end_of_stream_error())
|
||||
Err(de::Error::end_of_stream())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user