Skip to content

Commit

Permalink
feat!: Add a new error type for handshake timeouts
Browse files Browse the repository at this point in the history
And make the errors enun non_exhaustive

BREAKING CHANGE: Adds a new variant to the Error Enum
BREAKING CHANGE: The Error enum is now non_exhaustive
BREAKING CHANGE: Now returns an error if a handshake times out
Fixes: #36
  • Loading branch information
tmccombs committed Sep 21, 2023
1 parent 31efb69 commit 62e233e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,19 @@ pub struct Builder<T> {

/// Wraps errors from either the listener or the TLS Acceptor
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum Error<LE: std::error::Error, TE: std::error::Error> {
/// An error that arose from the listener ([AsyncAccept::Error])
#[error("{0}")]
ListenerError(#[source] LE),
/// An error that occurred during the TLS accept handshake
#[error("{0}")]
TlsAcceptError(#[source] TE),
// TODO: is there any way we could include thee original connection, or maybe some
// info about it here?
/// The TLS handshake timed out
#[error("Timeout during TLS handshake")]
HandshakeTimeout(),
}

impl<A: AsyncAccept, T> TlsListener<A, T>
Expand Down Expand Up @@ -226,7 +232,7 @@ where
}
// The handshake timed out, try getting another connection from the
// queue
Poll::Ready(Some(Err(_))) => continue,
Poll::Ready(Some(Err(_))) => Poll::Ready(Some(Err(Error::HandshakeTimeout()))),
_ => Poll::Pending,
};
}
Expand Down

0 comments on commit 62e233e

Please sign in to comment.