mwkeep 0.0.1

A tool for house keeping MediaWiki sites.
//! Application specific custom Serialization/Deserialization error type

use std::{fmt, io};

/// Application specific custom Serialization/Deserialization error type
#[derive(Debug)]
pub enum Error {
    IoError(io::Error),
    DeError(toml::de::Error),
    SerError(toml::ser::Error),
}

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Self::IoError(err) => err.fmt(f),
            Self::DeError(err) => err.fmt(f),
            Self::SerError(err) => err.fmt(f),
        }
    }
}

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

impl From<io::Error> for Error {
    fn from(err: io::Error) -> Self {
        Self::IoError(err)
    }
}

impl From<toml::de::Error> for Error {
    fn from(err: toml::de::Error) -> Self {
        Self::DeError(err)
    }
}

impl From<toml::ser::Error> for Error {
    fn from(err: toml::ser::Error) -> Self {
        Self::SerError(err)
    }
}