rocket::http::hyper::net

Trait NetworkListener

Source
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§

Source

type Stream: NetworkStream + Send + Clone

The stream produced for each connection.

Required Methods§

Source

fn accept(&mut self) -> Result<Self::Stream, Error>

Returns an iterator of streams.

Source

fn local_addr(&mut self) -> Result<SocketAddr, Error>

Get the address this Listener ended up listening on.

Provided Methods§

Source

fn incoming(&mut self) -> NetworkConnections<'_, Self>

Returns an iterator over incoming connections.

Source

fn set_read_timeout(&mut self, _: Option<Duration>)

Sets the read timeout for all streams that are accepted

Source

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.

Implementors§