pub trait Protocol<IO, B>{
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§
Sourcetype Connection: Connection<B>
type Connection: Connection<B>
The type of connection returned by this service
Required Methods§
Sourcefn connect(
&mut self,
transport: IO,
version: HttpProtocol,
) -> <Self as Protocol<IO, B>>::Future
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.