Trait rusty_box::http_client::common::BaseHttpClient
source · pub trait BaseHttpClient: Send + Default + Clone + Debug {
type Error;
// Required methods
fn get<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
url: &'life1 str,
headers: Option<&'life2 Headers>,
payload: &'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, 'life4, 'async_trait>(
&'life0 self,
url: &'life1 str,
headers: Option<&'life2 Headers>,
query: Option<&'life3 Query<'_>>,
payload: &'life4 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,
'life4: 'async_trait;
fn post_form<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
url: &'life1 str,
headers: Option<&'life2 Headers>,
payload: &'life3 Form<'life4>
) -> 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,
'life4: 'async_trait;
fn put<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
url: &'life1 str,
headers: Option<&'life2 Headers>,
query: Option<&'life3 Query<'_>>,
payload: &'life4 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,
'life4: 'async_trait;
fn delete<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
url: &'life1 str,
headers: Option<&'life2 Headers>,
payload: &'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 represents the interface to be implemented for an HTTP client, which is kept separate from the Box client for cleaner code. Thus, it also requires other basic traits that are needed for the Box client.
When a request doesn’t need to pass parameters, the empty or default value
of the payload type should be passed, like json!({}) or Query::new().
This avoids using Option<T> because Value itself may be null in other
different ways (Value::Null, an empty Value::Object…), so this removes
redundancy and edge cases (a `Some(Value::Null), for example, doesn’t make
much sense).