Skip to content

Commit

Permalink
Add tokio_boring::HandshakeError::as_source_stream
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Mar 9, 2021
1 parent 66cabd8 commit 8fc84f0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tokio-boring/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
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<S> fmt::Debug for HandshakeError<S>
Expand Down

0 comments on commit 8fc84f0

Please sign in to comment.