diff --git a/tokio-boring/src/lib.rs b/tokio-boring/src/lib.rs index 750e1ee1..1ed5c25a 100644 --- a/tokio-boring/src/lib.rs +++ b/tokio-boring/src/lib.rs @@ -277,13 +277,21 @@ impl HandshakeError { } } - /// Converts error to the source data stream tha was used for the handshake. + /// Converts error to the source data stream that was used for the handshake. pub fn into_source_stream(self) -> Option { match self.0 { ssl::HandshakeError::Failure(s) => Some(s.into_source_stream().stream), _ => None, } } + + /// Returns a reference to the source data stream. + pub fn as_source_stream(&self) -> Option<&S> { + match &self.0 { + ssl::HandshakeError::Failure(s) => Some(&s.get_ref().stream), + _ => None, + } + } } impl fmt::Debug for HandshakeError