Merge pull request #25 from nox/expose-io-error

Provide access to inner I/O error during handshake
This commit is contained in:
Ivan Nikulin 2021-04-06 12:05:38 +01:00 committed by GitHub
commit 3838b11fb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

@ -3,6 +3,7 @@
clippy::redundant_static_lifetimes, clippy::redundant_static_lifetimes,
clippy::too_many_arguments, clippy::too_many_arguments,
clippy::unreadable_literal, clippy::unreadable_literal,
clippy::upper_case_acronyms,
improper_ctypes, improper_ctypes,
non_camel_case_types, non_camel_case_types,
non_snake_case, non_snake_case,

View File

@ -213,7 +213,7 @@ use ffi::{BIO_get_data, BIO_set_data, BIO_set_flags, BIO_set_init};
#[allow(bad_style)] #[allow(bad_style)]
unsafe fn BIO_set_num(_bio: *mut ffi::BIO, _num: c_int) {} unsafe fn BIO_set_num(_bio: *mut ffi::BIO, _num: c_int) {}
#[allow(bad_style)] #[allow(bad_style, clippy::upper_case_acronyms)]
struct BIO_METHOD(*mut ffi::BIO_METHOD); struct BIO_METHOD(*mut ffi::BIO_METHOD);
impl BIO_METHOD { impl BIO_METHOD {

View File

@ -292,6 +292,14 @@ impl<S> HandshakeError<S> {
_ => None, _ => None,
} }
} }
/// Returns a reference to the inner I/O error, if any.
pub fn as_io_error(&self) -> Option<&io::Error> {
match &self.0 {
ssl::HandshakeError::Failure(s) => s.error().io_error(),
_ => None,
}
}
} }
impl<S> fmt::Debug for HandshakeError<S> impl<S> fmt::Debug for HandshakeError<S>