preserves 5.0.0-rc.9

Implementation of the Preserves serialization format.
Documentation
use std::convert::From;
use std::io;

#[derive(Debug)]
pub enum Error {
    Preserves(crate::Error),
    Message(String),
    InvalidUnicodeScalar(u32),
    CannotDeserializeAny,
    ExpectedOption,
    ExpectedUnicodeScalar,
}

impl From<crate::Error> for Error {
    fn from(e: crate::Error) -> Self {
        Error::Preserves(e)
    }
}

impl From<io::Error> for Error {
    fn from(e: io::Error) -> Self {
        Error::Preserves(e.into())
    }
}

impl From<Error> for io::Error {
    fn from(e: Error) -> Self {
        match e {
            Error::Preserves(crate::Error::Io(i)) => i,
            other => io::Error::other(other),
        }
    }
}

impl serde::ser::Error for Error {
    fn custom<T: std::fmt::Display>(msg: T) -> Self {
        Self::Message(msg.to_string())
    }
}

impl serde::de::Error for Error {
    fn custom<T: std::fmt::Display>(msg: T) -> Self {
        Self::Message(msg.to_string())
    }
}

impl std::error::Error for Error {}

impl std::fmt::Display for Error {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{:?}", self)
    }
}