Extract run_unix_listener extension method

This commit is contained in:
Val Packett 2025-07-17 21:20:53 -03:00
parent e4bace1793
commit 71aecea297
2 changed files with 19 additions and 6 deletions

View file

@ -76,6 +76,18 @@ impl HostedBus {
}
}
pub trait SharedHostedBus {
async fn run_unix_listener(self, listener: tokio::net::UnixListener);
}
impl SharedHostedBus for Arc<tokio::sync::Mutex<HostedBus>> {
async fn run_unix_listener(self, listener: tokio::net::UnixListener) {
while let Ok((socket, _remote_addr)) = listener.accept().await {
self.lock().await.connect_unix(socket).await.unwrap()
}
}
}
pub struct NameOwnerStream {
_conn: zbus::Connection,
stream: zbus::MessageStream,