Add kind method

This commit is contained in:
asonix 2020-06-06 14:30:37 -05:00
parent 118515ec36
commit 9fbf73ad1b

View file

@ -54,6 +54,15 @@ pub enum Error {
Canceled,
}
impl Error {
pub fn kind(&self) -> Option<io::ErrorKind> {
match self {
Error::Io(ref io) => Some(io.kind()),
_ => None,
}
}
}
impl From<std::str::Utf8Error> for Error {
fn from(e: std::str::Utf8Error) -> Self {
Error::Io(io::Error::new(io::ErrorKind::InvalidInput, e))