Trait Connection

Source
pub trait Connection<B> {
    type ResBody: Body + Send + 'static;
    type Error: Error + Send + Sync + 'static;
    type Future: Future<Output = Result<Response<Self::ResBody>, Self::Error>> + Send + 'static;

    // Required methods
    fn send_request(&mut self, request: Request<B>) -> Self::Future;
    fn poll_ready(
        &mut self,
        cx: &mut Context<'_>,
    ) -> Poll<Result<(), Self::Error>>;
    fn version(&self) -> Version;
}
Available on crate feature client only.
Expand description

A connection to a remote server which can send and recieve HTTP requests/responses.

Underneath, it may not use HTTP as the connection protocol, and it may use any appropriate transport protocol to connect to the server.

Required Associated Types§

Source

type ResBody: Body + Send + 'static

The body type for responses this connection

Source

type Error: Error + Send + Sync + 'static

The error type for this connection

Source

type Future: Future<Output = Result<Response<Self::ResBody>, Self::Error>> + Send + 'static

The future type returned by this service

Required Methods§

Source

fn send_request(&mut self, request: Request<B>) -> Self::Future

Send a request to the remote server and return the response.

Source

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

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

Source

fn version(&self) -> Version

What HTTP version is this connection using?

Implementors§

Source§

impl Connection<Body> for MockSender

Available on crate feature mocks only.
Source§

impl<B> Connection<B> for HttpConnection<B>
where B: HttpBody + Send + 'static,

Source§

impl<C, B> Connection<B> for Pooled<C, B>
where C: PoolableConnection<B>, B: Send + 'static,

Source§

type ResBody = <C as Connection<B>>::ResBody

Source§

type Error = <C as Connection<B>>::Error

Source§

type Future = <C as Connection<B>>::Future