Skip to main content

Client

Trait Client 

Source
pub trait Client<B>
where B: Body + Send + 'static, <B as Body>::Data: Send, B::Error: Send + Sync + 'static,
{ // Required method fn send( &self, req: Request<B>, ) -> impl Future<Output = Result<Response<Incoming>, Error>> + Send; }
Expand description

An HTTP client that can asynchronously send requests and receive responses.

This trait is HTTP version agnostic; it can be implemented for any version of HTTP. Version-specific features, such as connecting to a server or the HTTP/1.1 protocol upgrade mechanism, must be implemented individually for concrete implementations in addition to the send method.

Required Methods§

Source

fn send( &self, req: Request<B>, ) -> impl Future<Output = Result<Response<Incoming>, Error>> + Send

Sends the given HTTP Request to the connected server and returns the Response.

Note that the Response body of Incoming means the body must be collected separately from the Response status and headers; this allows the status/headers to be checked before the full body has arrived.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T, B> Client<B> for &T
where T: Client<B>, B: Body + Send + 'static, <B as Body>::Data: Send, B::Error: Send + Sync + 'static,

Source§

fn send( &self, req: Request<B>, ) -> impl Future<Output = Result<Response<Incoming>, Error>> + Send

Source§

impl<T, B> Client<B> for &mut T
where T: Client<B>, B: Body + Send + 'static, <B as Body>::Data: Send, B::Error: Send + Sync + 'static,

Source§

fn send( &self, req: Request<B>, ) -> impl Future<Output = Result<Response<Incoming>, Error>> + Send

Source§

impl<T, B> Client<B> for Arc<T>
where T: Client<B>, B: Body + Send + 'static, <B as Body>::Data: Send, B::Error: Send + Sync + 'static,

Source§

fn send( &self, req: Request<B>, ) -> impl Future<Output = Result<Response<Incoming>, Error>> + Send

Implementors§

Source§

impl<B> Client<B> for Http1<B>
where B: Body + Send + 'static, B::Data: Send, B::Error: Send + Sync + 'static,

Source§

impl<B> Client<B> for Http2<B>
where B: Body + Send + 'static, B::Data: Send, B::Error: Send + Sync + 'static,