pub trait HttpClientAsync: Send {
// Required methods
fn run<C, T, E>(
&mut self,
coroutine: C,
) -> impl Future<Output = Result<T, HttpClientError>> + Send
where C: HttpCoroutine<Yield = HttpYield, Return = Result<T, E>> + Send,
T: Send,
E: Send,
HttpClientError: From<E>;
fn run_send<C, E>(
&mut self,
coroutine: C,
) -> impl Future<Output = Result<HttpSendOutput, HttpClientError>> + Send
where C: HttpCoroutine<Yield = HttpSendYield, Return = Result<HttpSendOutput, E>> + Send,
E: Send,
HttpClientError: From<E>;
// Provided methods
fn send(
&mut self,
request: HttpRequest,
) -> impl Future<Output = Result<HttpSendOutput, HttpClientError>> + Send { ... }
fn send_http10(
&mut self,
request: HttpRequest,
) -> impl Future<Output = Result<HttpSendOutput, HttpClientError>> + Send { ... }
}client only.Expand description
Async HTTP request surface, the HttpClient twin for callers
whose transport is a future.
Everything HttpClient documents applies here, plus the Send
bounds. They are load-bearing rather than defensive: a plain async fn in a trait cannot promise that the future it returns is Send,
so anything built from the default bodies would fail to compile
under tokio::spawn, which is the first thing a worker-spawning
consumer reaches for. Declaring the return type explicitly as impl Future<..> + Send, with Send as a supertrait so &mut Self
carries through, keeps the defaults spawnable.
HttpClient deliberately carries no such bound. A blocking call
returns a value, so there is no future whose auto-traits need
pinning down, and requiring Send there would exclude a perfectly
good client built on a thread-affine handle.
Required Methods§
Sourcefn run<C, T, E>(
&mut self,
coroutine: C,
) -> impl Future<Output = Result<T, HttpClientError>> + Sendwhere
C: HttpCoroutine<Yield = HttpYield, Return = Result<T, E>> + Send,
T: Send,
E: Send,
HttpClientError: From<E>,
fn run<C, T, E>(
&mut self,
coroutine: C,
) -> impl Future<Output = Result<T, HttpClientError>> + Sendwhere
C: HttpCoroutine<Yield = HttpYield, Return = Result<T, E>> + Send,
T: Send,
E: Send,
HttpClientError: From<E>,
Runs a standard-shape coroutine to completion, fulfilling its read and write requests against the transport.
Sourcefn run_send<C, E>(
&mut self,
coroutine: C,
) -> impl Future<Output = Result<HttpSendOutput, HttpClientError>> + Sendwhere
C: HttpCoroutine<Yield = HttpSendYield, Return = Result<HttpSendOutput, E>> + Send,
E: Send,
HttpClientError: From<E>,
fn run_send<C, E>(
&mut self,
coroutine: C,
) -> impl Future<Output = Result<HttpSendOutput, HttpClientError>> + Sendwhere
C: HttpCoroutine<Yield = HttpSendYield, Return = Result<HttpSendOutput, E>> + Send,
E: Send,
HttpClientError: From<E>,
Runs a request coroutine to completion, deciding what a redirect means along the way.
Provided Methods§
Sourcefn send(
&mut self,
request: HttpRequest,
) -> impl Future<Output = Result<HttpSendOutput, HttpClientError>> + Send
fn send( &mut self, request: HttpRequest, ) -> impl Future<Output = Result<HttpSendOutput, HttpClientError>> + Send
Sends one HTTP/1.1 request and reads its response.
Sourcefn send_http10(
&mut self,
request: HttpRequest,
) -> impl Future<Output = Result<HttpSendOutput, HttpClientError>> + Send
fn send_http10( &mut self, request: HttpRequest, ) -> impl Future<Output = Result<HttpSendOutput, HttpClientError>> + Send
HTTP/1.0 counterpart of send.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".