From 12e0d26945cf8cf1faa83dcd1c05235a61cfb436 Mon Sep 17 00:00:00 2001 From: samamill Date: Mon, 24 Sep 2018 10:12:46 -0700 Subject: [PATCH] Added functions to access io::Error in h2::Error (#311) Fixes #310 --- src/error.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/error.rs b/src/error.rs index d8a747c..6d2a7b6 100644 --- a/src/error.rs +++ b/src/error.rs @@ -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 { + match self.kind { + Kind::Io(e) => Some(e), + _ => None, + } + } } impl From for Error {