|
|
|
@ -1,3 +1,5 @@
|
|
|
|
|
use std::fmt;
|
|
|
|
|
use std::error;
|
|
|
|
|
use std::ffi;
|
|
|
|
|
use nix;
|
|
|
|
|
|
|
|
|
@ -39,3 +41,28 @@ impl From<udev::Error> for Error {
|
|
|
|
|
Error::Udev(value)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl fmt::Display for Error {
|
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
|
|
|
|
f.write_str(error::Error::description(self))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl error::Error for Error {
|
|
|
|
|
fn description(&self) -> &str {
|
|
|
|
|
match self {
|
|
|
|
|
&Error::Nix(ref err) =>
|
|
|
|
|
err.description(),
|
|
|
|
|
|
|
|
|
|
&Error::Nul(ref err) =>
|
|
|
|
|
err.description(),
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "udev")]
|
|
|
|
|
&Error::Udev(ref err) =>
|
|
|
|
|
err.description(),
|
|
|
|
|
|
|
|
|
|
&Error::NotFound =>
|
|
|
|
|
"Device not found.",
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|