2020-02-14 12:20:17 +01:00
|
|
|
use std::io;
|
2020-02-16 16:02:03 +01:00
|
|
|
use toml;
|
|
|
|
|
|
|
|
use crate::auth::SASLError;
|
2020-02-14 12:20:17 +01:00
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum Error {
|
2020-02-16 16:02:03 +01:00
|
|
|
TomlDe(toml::de::Error),
|
|
|
|
TomlSer(toml::ser::Error),
|
|
|
|
SASL(SASLError),
|
|
|
|
IO(io::Error),
|
2020-02-18 16:55:19 +01:00
|
|
|
Boxed(Box<dyn std::error::Error>),
|
2020-02-16 16:02:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<SASLError> for Error {
|
|
|
|
fn from(e: SASLError) -> Error {
|
|
|
|
Error::SASL(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<io::Error> for Error {
|
|
|
|
fn from(e: io::Error) -> Error {
|
|
|
|
Error::IO(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<toml::de::Error> for Error {
|
|
|
|
fn from(e: toml::de::Error) -> Error {
|
|
|
|
Error::TomlDe(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<toml::ser::Error> for Error {
|
|
|
|
fn from(e: toml::ser::Error) -> Error {
|
|
|
|
Error::TomlSer(e)
|
|
|
|
}
|
2020-02-14 12:20:17 +01:00
|
|
|
}
|
|
|
|
|
2020-02-18 16:55:19 +01:00
|
|
|
impl From<Box<dyn std::error::Error>> for Error {
|
|
|
|
fn from(e: Box<dyn std::error::Error>) -> Error {
|
|
|
|
Error::Boxed(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-14 12:20:17 +01:00
|
|
|
pub type Result<T> = std::result::Result<T, Error>;
|