pub trait HttpClient: Send + Sync {
// Required methods
fn send<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 HttpRequest,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, HttpError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn download<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 HttpRequest,
writer: &'life2 mut (dyn Write + Send),
) -> Pin<Box<dyn Future<Output = Result<DownloadMeta, HttpError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided methods
fn wants_recorded_request(&self) -> bool { ... }
fn send_without_redirects_to<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_req: &'life1 HttpRequest,
_body: &'life2 mut (dyn Write + Send),
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, HttpError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn download_with_progress<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
req: &'life1 HttpRequest,
writer: &'life2 mut (dyn Write + Send),
progress: &'life3 DownloadProgress,
) -> Pin<Box<dyn Future<Output = Result<DownloadMeta, HttpError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
}Expand description
Embedder-supplied HTTP transport. 4xx/5xx are not errors; only transport
failures return Err(HttpError). Send + Sync for sharing across stores.
Implementations must enforce HttpRequest::transport_policy, including
redirect destinations, and must call HttpRequest::redirect_guard before
sending each redirect hop, returning its denial as
HttpError::PermissionDenied; a transport that follows redirects without
the guard bypasses the blueprint’s capability rules. Preserve
HttpError::Internal as a fatal host failure.
Required Methods§
fn send<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 HttpRequest,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, HttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn download<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 HttpRequest,
writer: &'life2 mut (dyn Write + Send),
) -> Pin<Box<dyn Future<Output = Result<DownloadMeta, HttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn download<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 HttpRequest,
writer: &'life2 mut (dyn Write + Send),
) -> Pin<Box<dyn Future<Output = Result<DownloadMeta, HttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
No default impl: the obvious “buffer via send then write_all” fallback
would silently break the bounded-memory guarantee http.download advertises.
Implementations must enforce the request’s timeout across the entire
transfer and its byte limit on both wire and decoded output.
Provided Methods§
Sourcefn wants_recorded_request(&self) -> bool
fn wants_recorded_request(&self) -> bool
Whether this client reads HttpRequest::recorded_as. The host functions
compute it only for a client that does.
Sourcefn send_without_redirects_to<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_req: &'life1 HttpRequest,
_body: &'life2 mut (dyn Write + Send),
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, HttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn send_without_redirects_to<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_req: &'life1 HttpRequest,
_body: &'life2 mut (dyn Write + Send),
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, HttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Sends req to exactly its URL, never following a redirect, even on
the same host, and writes the body to body as it arrives; the
returned response’s body is empty. Git fetches through it, streaming
packs to disk, so an implementation holds one chunk in memory however
large max_response_size is.
Embedders must opt in to this contract before Git can use their
transport: there is no buffering fallback, for the reason download
has none.
Sourcefn download_with_progress<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
req: &'life1 HttpRequest,
writer: &'life2 mut (dyn Write + Send),
progress: &'life3 DownloadProgress,
) -> Pin<Box<dyn Future<Output = Result<DownloadMeta, HttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn download_with_progress<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
req: &'life1 HttpRequest,
writer: &'life2 mut (dyn Write + Send),
progress: &'life3 DownloadProgress,
) -> Pin<Box<dyn Future<Output = Result<DownloadMeta, HttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Existing embedders report the bytes accepted by the destination. Override to count actual wire bytes, including bytes rejected before a write and compressed bytes. The default cannot observe those bytes.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".