Skip to main content

fetch_future

Function fetch_future 

Source
pub fn fetch_future(req: Request) -> FetchFuture ⓘ
Expand description

Start the request immediately and await the result. The future is the cancellation grip: dropping it cancels the request where the platform supports it (docs/http.md’s cancel matrix): Apple NSURLSessionTask.cancel, Android OkHttp Call.cancel, the web the fetch’s AbortController; Windows closes the WinHTTP request handle. A cancelled request that still completes resolves nothing; a platform-side cancel that beats the drop surfaces as HttpError::Cancelled.

Await it inside day::task (or any executor; the future is Send-agnostic plumbing over fetch_async’s completion): day::task(async move { let r = fetch_future(req).await; … }).