Skip to content

Commit 91d6fd7

Browse files
SabrinaJewsontmccombs
authored andcommitted
Add replace_acceptor_pin
1 parent 2d0aaef commit 91d6fd7

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/lib.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,14 @@ where
128128
A::Connection: AsyncRead + AsyncWrite + Unpin + 'static,
129129
A::Error: std::error::Error,
130130
T: AsyncTls<A::Connection>,
131-
Self: Unpin,
132131
{
133132
/// Accept the next connection
134133
///
135134
/// This is essentially an alias to `self.next()` with a more domain-appropriate name.
136-
pub fn accept(&mut self) -> impl Future<Output = Option<<Self as Stream>::Item>> + '_ {
135+
pub fn accept(&mut self) -> impl Future<Output = Option<<Self as Stream>::Item>> + '_
136+
where
137+
Self: Unpin,
138+
{
137139
self.next()
138140
}
139141

@@ -143,6 +145,15 @@ where
143145
pub fn replace_acceptor(&mut self, acceptor: T) {
144146
self.tls = acceptor;
145147
}
148+
149+
/// Replaces the Tls Acceptor configuration from a pinned reference to `Self`.
150+
///
151+
/// This is useful if your listener is `!Unpin`.
152+
///
153+
/// This can be used to change the certificate used at runtime.
154+
pub fn replace_acceptor_pin(self: Pin<&mut Self>, acceptor: T) {
155+
*self.project().tls = acceptor;
156+
}
146157
}
147158

148159
impl<A, T> Stream for TlsListener<A, T>

0 commit comments

Comments
 (0)