pub trait HttpClient: Send + Sync {
// Required methods
fn send(&self, request: HttpRequest);
fn poll(&self) -> Vec<(String, Result<HttpResponse, String>)>;
}Expand description
Abstract HTTP client.
The engine calls send to initiate a request and
poll each frame to collect completed responses.
Implementations must not block in either method.
§Object safety
The trait is object-safe so it can be stored as Box<dyn HttpClient>.
§Thread safety
Required to be Send + Sync because the engine state may be shared
across threads (e.g. between a main thread and a render thread).
Required Methods§
Sourcefn send(&self, request: HttpRequest)
fn send(&self, request: HttpRequest)
Initiate an HTTP request. Must return immediately.
The implementation should enqueue the request for background
execution and make the result available via poll.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".