Skip to main content

HttpClient

Trait HttpClient 

Source
pub trait HttpClient: Send + Sync {
    // Required methods
    fn get_value<'life0, 'life1, 'async_trait>(
        &'life0 self,
        url: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Value, HttpClientError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn post_form_value<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        url: &'life1 str,
        form: &'life2 [(String, String)],
        auth_header: Option<(&'life3 str, &'life4 str)>,
    ) -> Pin<Box<dyn Future<Output = Result<Value, HttpClientError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn post_json_value<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        url: &'life1 str,
        body: &'life2 Value,
        auth_header: Option<(&'life3 str, &'life4 str)>,
    ) -> Pin<Box<dyn Future<Output = Result<Value, HttpClientError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
}
Expand description

HTTP client trait for abstraction over different implementations

This trait uses serde_json::Value to maintain object safety

Required Methods§

Source

fn get_value<'life0, 'life1, 'async_trait>( &'life0 self, url: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Value, HttpClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Perform a GET request and return JSON value

Source

fn post_form_value<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, url: &'life1 str, form: &'life2 [(String, String)], auth_header: Option<(&'life3 str, &'life4 str)>, ) -> Pin<Box<dyn Future<Output = Result<Value, HttpClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Perform a POST request with form data and return JSON value

Source

fn post_json_value<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, url: &'life1 str, body: &'life2 Value, auth_header: Option<(&'life3 str, &'life4 str)>, ) -> Pin<Box<dyn Future<Output = Result<Value, HttpClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Perform a POST request with JSON body and return JSON value

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl HttpClient for ReqwestHttpClient

Available on crate feature http-reqwest and non-WebAssembly only.
Source§

impl HttpClient for ReqwestHttpClientWithAdminSupport

Available on crate feature http-reqwest and non-WebAssembly only.