forked from syndicate-lang/preserves
From<value::decoder::Error> for std::io::Error
This commit is contained in:
parent
8cdd67f5ba
commit
72edd1327a
|
@ -1,4 +1,4 @@
|
||||||
use std::io::Read;
|
use std::io::{Read, ErrorKind};
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use crate::value::value::{Value, AValue, Set, Dictionary};
|
use crate::value::value::{Value, AValue, Set, Dictionary};
|
||||||
|
@ -14,6 +14,16 @@ pub enum Error {
|
||||||
Eof,
|
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 {
|
impl From<std::io::Error> for Error {
|
||||||
fn from(v: std::io::Error) -> Self {
|
fn from(v: std::io::Error) -> Self {
|
||||||
Error::Io(v)
|
Error::Io(v)
|
||||||
|
|
Loading…
Reference in New Issue