use std::error::Error;
use std::fmt;
pub type Result<T> = ::std::result::Result<T, DescriptorError>;
#[derive(Clone, Copy, Debug)]
pub enum DescriptorError {
OpenFail,
CloseFail,
}
impl fmt::Display for DescriptorError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", ::errno::errno())
}
}
impl Error for DescriptorError {
fn description(&self) -> &str {
match *self {
DescriptorError::OpenFail => "can't open the fd",
DescriptorError::CloseFail => "can't close the fd",
}
}
fn cause(&self) -> Option<&Error> {
None
}
}