pub trait NetworkListener: Clone {
type Stream: NetworkStream + Send + Clone;
// Required methods
fn accept(&mut self) -> Result<Self::Stream, Error>;
fn local_addr(&mut self) -> Result<SocketAddr, Error>;
// Provided methods
fn incoming(&mut self) -> NetworkConnections<'_, Self> ⓘ { ... }
fn set_read_timeout(&mut self, _: Option<Duration>) { ... }
fn set_write_timeout(&mut self, _: Option<Duration>) { ... }
}
Expand description
An abstraction to listen for connections on a certain port.
Required Associated Types§
Sourcetype Stream: NetworkStream + Send + Clone
type Stream: NetworkStream + Send + Clone
The stream produced for each connection.
Required Methods§
Sourcefn local_addr(&mut self) -> Result<SocketAddr, Error>
fn local_addr(&mut self) -> Result<SocketAddr, Error>
Get the address this Listener ended up listening on.
Provided Methods§
Sourcefn incoming(&mut self) -> NetworkConnections<'_, Self> ⓘ
fn incoming(&mut self) -> NetworkConnections<'_, Self> ⓘ
Returns an iterator over incoming connections.
Sourcefn set_read_timeout(&mut self, _: Option<Duration>)
fn set_read_timeout(&mut self, _: Option<Duration>)
Sets the read timeout for all streams that are accepted
Sourcefn set_write_timeout(&mut self, _: Option<Duration>)
fn set_write_timeout(&mut self, _: Option<Duration>)
Sets the write timeout for all streams that are accepted
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.