Skip to main content

ClientExt

Trait ClientExt 

Source
pub trait ClientExt<B>: Client<B>
where B: Body + Send + 'static, <B as Body>::Data: Send, B::Error: Send + Sync + 'static,
{ // Provided methods fn get( &self, url: &Url, headers: impl IntoIterator<Item = (HeaderName, HeaderValue)>, ) -> impl Future<Output = Result<Response<Incoming>, Error>> where B: Default { ... } fn post( &self, url: &Url, headers: impl IntoIterator<Item = (HeaderName, HeaderValue)>, body: B, ) -> impl Future<Output = Result<Response<Incoming>, Error>> { ... } }
Expand description

Extension trait adding specific HTTP method functions (GET, POST, etc.) on top of the base Client trait.

Provided Methods§

Source

fn get( &self, url: &Url, headers: impl IntoIterator<Item = (HeaderName, HeaderValue)>, ) -> impl Future<Output = Result<Response<Incoming>, Error>>
where B: Default,

Sends an HTTP GET request to the connected server and returns the Response.

By definition, HTTP GET requests do not contain a body. 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.

Source

fn post( &self, url: &Url, headers: impl IntoIterator<Item = (HeaderName, HeaderValue)>, body: B, ) -> impl Future<Output = Result<Response<Incoming>, Error>>

Sends an HTTP POST 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".

Implementors§

Source§

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