use std;
use std::fmt;
use std::error::Error as Stderr;
use std::convert::From;
#[derive(Debug)]
pub enum Error {
TooLarge,
OutOfBounds,
ParseError,
Unspecified,
ListenError
}
impl Stderr for Error {
fn description(&self) -> &str {
match *self {
Error::TooLarge => "Error signing data",
Error::OutOfBounds => "Out of bounds",
Error::ParseError => "Error parsing",
Error::Unspecified => "Unspecified error",
Error::ListenError => "Listen error",
}
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl From<std::net::AddrParseError> for Error {
fn from(_error: std::net::AddrParseError) -> Self {
Error::ParseError
}
}