Added functions to access io::Error in h2::Error (#311)

Fixes #310
This commit is contained in:
samamill
2018-09-24 10:12:46 -07:00
committed by Carl Lerche
parent 586106adf2
commit 12e0d26945

View File

@@ -49,6 +49,30 @@ impl Error {
_ => None,
}
}
/// Returns the true if the error is an io::Error
pub fn is_io(&self) -> bool {
match self.kind {
Kind::Io(_) => true,
_ => false,
}
}
/// Returns the error if the error is an io::Error
pub fn get_io(&self) -> Option<&io::Error> {
match self.kind {
Kind::Io(ref e) => Some(e),
_ => None,
}
}
/// Returns the error if the error is an io::Error
pub fn into_io(self) -> Option<io::Error> {
match self.kind {
Kind::Io(e) => Some(e),
_ => None,
}
}
}
impl From<proto::Error> for Error {