Add tokio_boring::HandshakeError::as_source_stream

This commit is contained in:
Anthony Ramine 2021-03-09 13:58:12 +01:00
parent 66cabd882c
commit 8fc84f01e0
1 changed files with 9 additions and 1 deletions

View File

@ -277,13 +277,21 @@ impl<S> HandshakeError<S> {
} }
} }
/// 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<S> { pub fn into_source_stream(self) -> Option<S> {
match self.0 { match self.0 {
ssl::HandshakeError::Failure(s) => Some(s.into_source_stream().stream), ssl::HandshakeError::Failure(s) => Some(s.into_source_stream().stream),
_ => None, _ => 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<S> fmt::Debug for HandshakeError<S> impl<S> fmt::Debug for HandshakeError<S>