From 2ec19bb7abdcf1cf70fae09c068b757a7fd06578 Mon Sep 17 00:00:00 2001 From: Karsten Becker <567973+KarstenB@users.noreply.github.com> Date: Wed, 9 Apr 2025 10:01:28 +0200 Subject: [PATCH] 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 --- src/asynchronous/server.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/asynchronous/server.rs b/src/asynchronous/server.rs index bbf3329b..25126df7 100644 --- a/src/asynchronous/server.rs +++ b/src/asynchronous/server.rs @@ -171,6 +171,15 @@ impl Server { Ok(()) } + pub async fn accept(&mut self, conn: Socket) -> std::io::Result<()> { + let delegate = ServerBuilder { + services: self.services.clone(), + streams: Arc::default(), + shutdown_waiter: self.shutdown.subscribe(), + }; + Connection::new(conn, delegate).run().await + } + pub async fn shutdown(&mut self) -> Result<()> { self.stop_listen().await; self.disconnect().await;