Trait HttpClient

Source
pub trait HttpClient:
    Debug
    + Default
    + Clone
    + Send {
    type Error: Debug + Display;

    // Required methods
    fn get<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        url: &'life1 str,
        api_key: &'life2 str,
        query: Option<&'life3 Query<'_>>,
    ) -> Pin<Box<dyn Future<Output = Result<String, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn post<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        url: &'life1 str,
        api_key: &'life2 str,
        body: &'life3 Value,
    ) -> Pin<Box<dyn Future<Output = Result<String, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn put<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        url: &'life1 str,
        api_key: &'life2 str,
        body: &'life3 Value,
    ) -> Pin<Box<dyn Future<Output = Result<String, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn delete<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        url: &'life1 str,
        api_key: &'life2 str,
        body: &'life3 Value,
    ) -> Pin<Box<dyn Future<Output = Result<String, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
}
Expand description

This trait is a collection of the stand HTTP methods for any client. The aim of the trait is to abstract ways the HTTP implementation found in different HTTP clients.

The goal is to give a level of flexibility to the user of the crate to work with their preferred HTTP client. To be as generic as possible, the U generic stands for the HTTP response. Ideally, it should be bounded to specific traits common in all response.

Required Associated Types§

Source

type Error: Debug + Display

HTTP error

Required Methods§

Source

fn get<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, url: &'life1 str, api_key: &'life2 str, query: Option<&'life3 Query<'_>>, ) -> Pin<Box<dyn Future<Output = Result<String, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Send http get request

Source

fn post<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, url: &'life1 str, api_key: &'life2 str, body: &'life3 Value, ) -> Pin<Box<dyn Future<Output = Result<String, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Send http post request

Source

fn put<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, url: &'life1 str, api_key: &'life2 str, body: &'life3 Value, ) -> Pin<Box<dyn Future<Output = Result<String, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Send http put request

Source

fn delete<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, url: &'life1 str, api_key: &'life2 str, body: &'life3 Value, ) -> Pin<Box<dyn Future<Output = Result<String, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Send http delete request

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.

Implementors§