pub trait HttpBackend:
Send
+ Sync
+ Debug {
// Required method
fn send<'life0, 'async_trait>(
&'life0 self,
request: HttpRequest,
) -> Pin<Box<dyn Future<Output = ApifyClientResult<HttpResponse>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn send_streaming<'life0, 'async_trait>(
&'life0 self,
request: HttpRequest,
) -> Pin<Box<dyn Future<Output = ApifyClientResult<StreamingHttpResponse>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
The replaceable transport contract.
Implementors are responsible only for sending a single request and returning the
raw response. Retries, authentication and serialization are handled by
HttpClient, so a backend only needs to perform one network round-trip.
Required Methods§
Sourcefn send<'life0, 'async_trait>(
&'life0 self,
request: HttpRequest,
) -> Pin<Box<dyn Future<Output = ApifyClientResult<HttpResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send<'life0, 'async_trait>(
&'life0 self,
request: HttpRequest,
) -> Pin<Box<dyn Future<Output = ApifyClientResult<HttpResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sends a single HTTP request and returns the response.
Network-level failures (connection refused, DNS, timeout) should be returned as
ApifyClientError::Http or ApifyClientError::Timeout. A non-2xx HTTP
status is not an error at this layer — return it as a normal HttpResponse.
Provided Methods§
Sourcefn send_streaming<'life0, 'async_trait>(
&'life0 self,
request: HttpRequest,
) -> Pin<Box<dyn Future<Output = ApifyClientResult<StreamingHttpResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_streaming<'life0, 'async_trait>(
&'life0 self,
request: HttpRequest,
) -> Pin<Box<dyn Future<Output = ApifyClientResult<StreamingHttpResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Like send, but for a request whose body the caller wants to process
incrementally (a live log or a large export) instead of fully buffered.
The default implementation just buffers the whole response via send and
yields it as a single chunk: correct for a custom backend that does not override this
(streaming still works end-to-end, just without a memory-usage benefit), while the
default ReqwestBackend overrides it for real constant-memory streaming through
reqwest’s own chunked body reader.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".