Skip to main content

Client

Trait Client 

Source
pub trait Client {
    type BodyWriter;
    type ResponseBody: Iterator<Item = Result<Bytes, Error>>;

    // Required method
    fn send(
        &self,
        req: Request<RequestBody<'_, Self::BodyWriter>>,
    ) -> Result<Response<Self::ResponseBody>, Error>;
}
Expand description

A trait implemented by HTTP client implementations.

Required Associated Types§

Source

type BodyWriter

The client’s binary request write type.

Source

type ResponseBody: Iterator<Item = Result<Bytes, Error>>

The client’s binary response body type.

Required Methods§

Source

fn send( &self, req: Request<RequestBody<'_, Self::BodyWriter>>, ) -> Result<Response<Self::ResponseBody>, Error>

Makes an HTTP request.

The request’s URI will be in absolute-form and it will always contain an Endpoint object in its extensions.

A response must only be returned if it has a 2xx status code. The client is responsible for handling all other status codes (for example, converting a 5xx response into a service error). The client is also responsible for decoding the response body if necessary.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§