From d8425015363cc0ac4742f938dc3f8e9d0beaa933 Mon Sep 17 00:00:00 2001 From: hozan23 Date: Thu, 30 Nov 2023 23:29:25 +0300 Subject: net: rename `Listener` trait to `ConnListener` --- net/src/listener.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'net/src/listener.rs') 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` +pub type Listener = Box; + +/// ConnListener is a generic network listener. #[async_trait] -pub trait Listener: Send + Sync { +pub trait ConnListener: Send + Sync { fn local_endpoint(&self) -> Result; async fn accept(&self) -> Result; } @@ -29,7 +32,7 @@ pub trait Listener: Send + Sync { /// }; /// /// ``` -pub async fn listen(endpoint: &Endpoint) -> Result> { +pub async fn listen(endpoint: &Endpoint) -> Result> { 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)?)), -- cgit v1.2.3