Skip to content

Commit 2ec19bb

Browse files
KarstenBjprendes
andcommitted
feat: add accept method
Add accept method for better error handling and ergononics when only one connection is expected. Fixes #293 Signed-off-by: Karsten Becker <567973+KarstenB@users.noreply.github.com> Co-authored-by: Jorge Prendes <jorge.prendes@gmail.com>
1 parent 4929e90 commit 2ec19bb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/asynchronous/server.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,15 @@ impl Server {
171171
Ok(())
172172
}
173173

174+
pub async fn accept(&mut self, conn: Socket) -> std::io::Result<()> {
175+
let delegate = ServerBuilder {
176+
services: self.services.clone(),
177+
streams: Arc::default(),
178+
shutdown_waiter: self.shutdown.subscribe(),
179+
};
180+
Connection::new(conn, delegate).run().await
181+
}
182+
174183
pub async fn shutdown(&mut self) -> Result<()> {
175184
self.stop_listen().await;
176185
self.disconnect().await;

0 commit comments

Comments
 (0)