pub trait HttpClient:
Send
+ Sync
+ 'static {
// Required method
fn send<'life0, 'async_trait>(
&'life0 self,
request: HttpRequest,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, HttpError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Sends HTTP requests.
Crates such as agentai-image send their requests through this trait instead of a
particular HTTP client. ReqwestClient (feature reqwest) implements it.
The returned future is Send. Clients whose futures are not Send (for example in the
browser) will need a relaxed bound, which comes with WebAssembly support.
Required Methods§
Sourcefn send<'life0, 'async_trait>(
&'life0 self,
request: HttpRequest,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, HttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send<'life0, 'async_trait>(
&'life0 self,
request: HttpRequest,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, HttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sends the request and reads the whole response. A response with an error status is
still Ok; only failures to send or read are errors.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".