pub trait Transport: Any + AsyncRead + AsyncWrite + Unpin + Send + Sync + 'static {
    // Provided methods
    fn set_linger(&mut self, linger: Option<Duration>) -> Result<(), Error> { ... }
    fn set_nodelay(&mut self, nodelay: bool) -> Result<(), Error> { ... }
    fn set_ip_ttl(&mut self, ttl: u32) -> Result<(), Error> { ... }
    fn peer_addr(&self) -> Result<Option<SocketAddr>, Error> { ... }
}
Expand description

The interface that the http protocol is communicated over.

This trait supports several common interfaces supported by tcp streams, but also can be implemented for other stream types. All trait functions are currently optional.

Note: Transport is currently designed around AsyncWrite and AsyncRead from the futures crate, which are different from the tokio AsyncRead and AsyncWrite traits. Hopefully this is a temporary situation.

Provided Methods§

fn set_linger(&mut self, linger: Option<Duration>) -> Result<(), Error>

Sets the linger duration of this transport by setting the SO_LINGER option

See std::net::TcpStream::set_linger Optional to implement.

Errors

Return an error if this transport supports setting linger and attempting to do so is unsuccessful.

fn set_nodelay(&mut self, nodelay: bool) -> Result<(), Error>

Sets the value of the TCP_NODELAY option on this transport.

See std::net::TcpStream::set_nodelay. Optional to implement.

Errors

Return an error if this transport supports setting nodelay and attempting to do so is unsuccessful.

fn set_ip_ttl(&mut self, ttl: u32) -> Result<(), Error>

Sets the value for the IP_TTL option on this transport.

See std::net::TcpStream::set_ttl Optional to implement

Errors

Return an error if this transport supports setting ttl and attempting to do so is unsuccessful.

fn peer_addr(&self) -> Result<Option<SocketAddr>, Error>

Returns the socket address of the remote peer of this transport.
Errors

Return an error if this transport supports retrieving the remote peer but attempting to do so is unsuccessful.

Trait Implementations§

§

impl Transport for Box<dyn Transport>

§

fn set_linger(&mut self, linger: Option<Duration>) -> Result<(), Error>

Sets the linger duration of this transport by setting the SO_LINGER option Read more
§

fn set_nodelay(&mut self, nodelay: bool) -> Result<(), Error>

Sets the value of the TCP_NODELAY option on this transport. Read more
§

fn set_ip_ttl(&mut self, ttl: u32) -> Result<(), Error>

Sets the value for the IP_TTL option on this transport. Read more
§

fn peer_addr(&self) -> Result<Option<SocketAddr>, Error>

Returns the socket address of the remote peer of this transport. Read more

Implementations on Foreign Types§

§

impl Transport for Box<dyn Transport>

§

fn set_linger(&mut self, linger: Option<Duration>) -> Result<(), Error>

§

fn set_nodelay(&mut self, nodelay: bool) -> Result<(), Error>

§

fn set_ip_ttl(&mut self, ttl: u32) -> Result<(), Error>

§

fn peer_addr(&self) -> Result<Option<SocketAddr>, Error>

Implementors§

§

impl Transport for BoxedTransport

§

impl Transport for Synthetic

source§

impl<T, U> Transport for Binding<T, U>
where T: Transport, U: Transport,