diff --git a/src/errors.rs b/src/errors.rs index 0c5c46e3..53e0e21f 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -318,6 +318,8 @@ pub mod serialize { pub enum DeError { /// Serde custom error Custom(String), + /// IO error from Writer + Io(Arc), /// Xml parsing error InvalidXml(Error), /// Cannot parse to integer @@ -368,6 +370,7 @@ pub mod serialize { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { DeError::Custom(s) => write!(f, "{}", s), + DeError::Io(e) => write!(f, "{}", e), DeError::InvalidXml(e) => write!(f, "{}", e), DeError::InvalidInt(e) => write!(f, "{}", e), DeError::InvalidFloat(e) => write!(f, "{}", e), @@ -409,6 +412,13 @@ pub mod serialize { } } + impl From for DeError { + #[inline] + fn from(e: IoError) -> Self { + Self::Io(Arc::new(e)) + } + } + impl From for DeError { #[inline] fn from(e: Error) -> Self {