Skip to main content

RequestBuilderExt

Trait RequestBuilderExt 

Source
pub trait RequestBuilderExt {
    // Required methods
    fn with_retry(self) -> RetriableRequestBuilder;
    fn send_json<'async_trait, T>(
        self,
    ) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
       where T: 'async_trait + DeserializeOwned + 'static,
             Self: 'async_trait;
    fn send_xml<'async_trait, T>(
        self,
    ) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
       where T: 'async_trait + DeserializeOwned + 'static,
             Self: 'async_trait;
    fn send_no_response<'async_trait>(
        self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait;
    fn send_raw<'async_trait>(
        self,
    ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
       where Self: 'async_trait;
}
Expand description

Extension trait for reqwest::RequestBuilder to add JSON and XML response handling

Required Methods§

Source

fn with_retry(self) -> RetriableRequestBuilder

Enable retries with an exponential back-off strategy.

Example:

let obj: MyType = client
    .get("https://api.example.com/obj")
    .with_retry()                // <- enable retries
    .send_json()                // <- deserialize JSON body
    .await?;
Source

fn send_json<'async_trait, T>( self, ) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
where T: 'async_trait + DeserializeOwned + 'static, Self: 'async_trait,

Send the request and parse the response as JSON

Source

fn send_xml<'async_trait, T>( self, ) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
where T: 'async_trait + DeserializeOwned + 'static, Self: 'async_trait,

Send the request and parse the response as XML

Source

fn send_no_response<'async_trait>( self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,

Send the request without parsing the response body

Source

fn send_raw<'async_trait>( self, ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
where Self: 'async_trait,

Send the request and return the raw response for custom handling

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl RequestBuilderExt for RequestBuilder

Source§

fn with_retry(self) -> RetriableRequestBuilder

Source§

fn send_json<'async_trait, T>( self, ) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
where T: 'async_trait + DeserializeOwned + 'static, Self: 'async_trait,

Source§

fn send_xml<'async_trait, T>( self, ) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
where T: 'async_trait + DeserializeOwned + 'static, Self: 'async_trait,

Source§

fn send_no_response<'async_trait>( self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,

Source§

fn send_raw<'async_trait>( self, ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
where Self: 'async_trait,

Implementors§