Factor out value deserializers

This commit is contained in:
Erick Tryzelaar
2015-03-31 12:56:17 -07:00
parent bfe7a04c4d
commit 54009e0991
4 changed files with 432 additions and 20 deletions
+16
View File
@@ -145,6 +145,22 @@ impl error::FromError<io::Error> for Error {
}
}
impl error::FromError<de::value::Error> for Error {
fn from_error(error: de::value::Error) -> Error {
match error {
de::value::Error::SyntaxError => {
de::Error::syntax_error()
}
de::value::Error::EndOfStreamError => {
de::Error::end_of_stream_error()
}
de::value::Error::MissingFieldError(field) => {
de::Error::missing_field_error(field)
}
}
}
}
impl de::Error for Error {
fn syntax_error() -> Error {
Error::SyntaxError(ErrorCode::ExpectedSomeValue, 0, 0)