Skip to main content

HttpService

Trait HttpService 

Source
pub trait HttpService:
    Debug
    + Send
    + Sync
    + 'static {
    // Required method
    fn call(
        &self,
        request: Request,
    ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + '_>>;
}
Expand description

An abstraction over HTTP request execution.

This trait allows decoupling request building (which uses reqwest::RequestBuilder) from request execution. The primary use case is SpawnService, which spawns execution on a dedicated I/O runtime – useful when the CPU runtime has I/O disabled.

Required Methods§

Source

fn call( &self, request: Request, ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + '_>>

Execute an HTTP request, returning the response.

The error type is crate::Error. Implementations that perform the actual network I/O surface transport failures as crate::Error::ReqwestError, which the retry layer inspects to decide whether a failure is retryable. Other variants (e.g. a cancelled I/O task) are treated as non-retryable.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§