pub trait HttpClient: Send + Sync {
// Required method
fn request<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
method: &'life1 str,
url: &'life2 str,
headers: &'life3 HashMap<String, String>,
body: Option<&'life4 [u8]>,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait;
// Provided methods
fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
url: &'life1 str,
headers: &'life2 HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn post<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
url: &'life1 str,
headers: &'life2 HashMap<String, String>,
body: &'life3 [u8],
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
}Expand description
Platform-agnostic HTTP client.
Implementors provide transport-level HTTP operations. The native
implementation uses reqwest; a WASM implementation would use fetch.
Required Methods§
Sourcefn request<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
method: &'life1 str,
url: &'life2 str,
headers: &'life3 HashMap<String, String>,
body: Option<&'life4 [u8]>,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn request<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
method: &'life1 str,
url: &'life2 str,
headers: &'life3 HashMap<String, String>,
body: Option<&'life4 [u8]>,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Send an HTTP request with the given method, URL, headers, and optional body.
Provided Methods§
Sourcefn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
url: &'life1 str,
headers: &'life2 HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
url: &'life1 str,
headers: &'life2 HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Send an HTTP GET request.
Sourcefn post<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
url: &'life1 str,
headers: &'life2 HashMap<String, String>,
body: &'life3 [u8],
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, Box<dyn Error + Send + Sync>>> + 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,
headers: &'life2 HashMap<String, String>,
body: &'life3 [u8],
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Send an HTTP POST request with a body.