Split out general std::io::Error wrapper
This commit is contained in:
parent
94058b5ec2
commit
1011818be6
|
@ -0,0 +1,30 @@
|
|||
#[derive(Debug)]
|
||||
pub struct Error {
|
||||
inner: std::io::Error,
|
||||
}
|
||||
|
||||
impl std::convert::From<Error> for std::io::Error {
|
||||
fn from(e: Error) -> Self {
|
||||
e.inner
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<std::io::Error> for Error {
|
||||
fn from(inner: std::io::Error) -> Self {
|
||||
Error { inner }
|
||||
}
|
||||
}
|
||||
|
||||
impl serde::ser::Error for Error {
|
||||
fn custom<T: std::fmt::Display>(msg: T) -> Self {
|
||||
Error { inner: std::io::Error::new(std::io::ErrorKind::Other, msg.to_string()) }
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::result::Result<(), std::fmt::Error> {
|
||||
self.inner.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for Error {}
|
|
@ -1,5 +1,6 @@
|
|||
pub mod de;
|
||||
pub mod ser;
|
||||
pub mod error;
|
||||
pub mod symbol;
|
||||
pub mod value;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use serde::Serialize;
|
||||
use super::value::writer::{self, Writer};
|
||||
use super::value::writer::Writer;
|
||||
use super::value::{
|
||||
Value, NestedValue, PlainValue,
|
||||
Domain, NullDomain,
|
||||
|
@ -7,39 +7,9 @@ use super::value::{
|
|||
Encoder,
|
||||
};
|
||||
|
||||
pub use super::error::Error;
|
||||
type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Error {
|
||||
inner: writer::Error,
|
||||
}
|
||||
|
||||
impl std::convert::From<Error> for writer::Error {
|
||||
fn from(e: Error) -> Self {
|
||||
e.inner
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<writer::Error> for Error {
|
||||
fn from(inner: writer::Error) -> Self {
|
||||
Error { inner }
|
||||
}
|
||||
}
|
||||
|
||||
impl serde::ser::Error for Error {
|
||||
fn custom<T: std::fmt::Display>(msg: T) -> Self {
|
||||
Error { inner: writer::Error::new(std::io::ErrorKind::Other, msg.to_string()) }
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::result::Result<(), std::fmt::Error> {
|
||||
self.inner.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for Error {}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Serializer<'a, W: Writer, N: NestedValue<D>, D: Domain> {
|
||||
pub write: &'a mut W,
|
||||
|
|
Loading…
Reference in New Issue