Trait Protocol

Source
pub trait Protocol<IO, B>
where IO: HasConnectionInfo, Self: Service<ProtocolRequest<IO, B>, Response = Self::Connection>,
{ type Error: Error + Send + Sync + 'static; type Connection: Connection<B>; type Future: Future<Output = Result<Self::Connection, <Self as Protocol<IO, B>>::Error>> + Send + 'static; // Required methods fn connect( &mut self, transport: IO, version: HttpProtocol, ) -> <Self as Protocol<IO, B>>::Future; fn poll_ready( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(), <Self as Protocol<IO, B>>::Error>>; }
Available on crate feature client only.
Expand description

Protocols (like HTTP) define how data is sent and received over a connection.

A protocol is a service which accepts a ProtocolRequest and returns a connection.

The request contains a transport stream and the HTTP protocol to use for the connection.

The connection is responsible for sending and receiving HTTP requests and responses.

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

Error returned when connection fails

Source

type Connection: Connection<B>

The type of connection returned by this service

Source

type Future: Future<Output = Result<Self::Connection, <Self as Protocol<IO, B>>::Error>> + Send + 'static

The type of the handshake future

Required Methods§

Source

fn connect( &mut self, transport: IO, version: HttpProtocol, ) -> <Self as Protocol<IO, B>>::Future

Connect to a remote server and return a connection.

The protocol version is provided to facilitate the correct handshake procedure.

Source

fn poll_ready( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(), <Self as Protocol<IO, B>>::Error>>

Poll the protocol to see if it is ready to accept a new connection.

Implementors§

Source§

impl<T, C, IO, B> Protocol<IO, B> for T
where IO: HasConnectionInfo, T: Service<ProtocolRequest<IO, B>, Response = C> + Send + 'static, T::Error: Error + Send + Sync + 'static, T::Future: Send + 'static, C: Connection<B>,