Skip to content

Commit

Permalink
Add replace_acceptor_pin
Browse files Browse the repository at this point in the history
  • Loading branch information
SabrinaJewson authored and tmccombs committed Mar 20, 2022
1 parent 2d0aaef commit 91d6fd7
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,14 @@ where
A::Connection: AsyncRead + AsyncWrite + Unpin + 'static,
A::Error: std::error::Error,
T: AsyncTls<A::Connection>,
Self: Unpin,
{
/// Accept the next connection
///
/// This is essentially an alias to `self.next()` with a more domain-appropriate name.
pub fn accept(&mut self) -> impl Future<Output = Option<<Self as Stream>::Item>> + '_ {
pub fn accept(&mut self) -> impl Future<Output = Option<<Self as Stream>::Item>> + '_
where
Self: Unpin,
{
self.next()
}

Expand All @@ -143,6 +145,15 @@ where
pub fn replace_acceptor(&mut self, acceptor: T) {
self.tls = acceptor;
}

/// Replaces the Tls Acceptor configuration from a pinned reference to `Self`.
///
/// This is useful if your listener is `!Unpin`.
///
/// This can be used to change the certificate used at runtime.
pub fn replace_acceptor_pin(self: Pin<&mut Self>, acceptor: T) {
*self.project().tls = acceptor;
}
}

impl<A, T> Stream for TlsListener<A, T>
Expand Down

0 comments on commit 91d6fd7

Please sign in to comment.