From<value::decoder::Error> for std::io::Error

This commit is contained in:
Tony Garnock-Jones 2019-09-20 21:42:45 +01:00
parent 8cdd67f5ba
commit 72edd1327a
1 changed files with 11 additions and 1 deletions

View File

@ -1,4 +1,4 @@
use std::io::Read;
use std::io::{Read, ErrorKind};
use std::convert::TryInto;
use std::convert::TryFrom;
use crate::value::value::{Value, AValue, Set, Dictionary};
@ -14,6 +14,16 @@ pub enum Error {
Eof,
}
impl From<Error> for std::io::Error {
fn from(v: Error) -> Self {
match v {
Error::Io(e) => e,
Error::Syntax(msg) => Self::new(ErrorKind::InvalidData, msg),
Error::Eof => Self::new(ErrorKind::UnexpectedEof, "Unexpected EOF"),
}
}
}
impl From<std::io::Error> for Error {
fn from(v: std::io::Error) -> Self {
Error::Io(v)