Skip to main content

HttpBackend

Trait HttpBackend 

Source
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;
}
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§

Source

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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§