diff options
Diffstat (limited to 'net/src/listener.rs')
-rw-r--r-- | net/src/listener.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/net/src/listener.rs b/net/src/listener.rs index c6c3d94..fcd1175 100644 --- a/net/src/listener.rs +++ b/net/src/listener.rs @@ -5,9 +5,12 @@ use crate::{ Conn, Endpoint, Error, Result, }; -/// Listener is a generic network listener. +/// Alias for `Box<dyn ConnListener>` +pub type Listener = Box<dyn ConnListener>; + +/// ConnListener is a generic network listener. #[async_trait] -pub trait Listener: Send + Sync { +pub trait ConnListener: Send + Sync { fn local_endpoint(&self) -> Result<Endpoint>; async fn accept(&self) -> Result<Conn>; } @@ -29,7 +32,7 @@ pub trait Listener: Send + Sync { /// }; /// /// ``` -pub async fn listen(endpoint: &Endpoint) -> Result<Box<dyn Listener>> { +pub async fn listen(endpoint: &Endpoint) -> Result<Box<dyn ConnListener>> { match endpoint { Endpoint::Tcp(addr, port) => Ok(Box::new(tcp::listen_tcp(addr, port).await?)), Endpoint::Unix(addr) => Ok(Box::new(unix::listen_unix(addr)?)), |