pub trait HttpBackend: Send + Sync {
// Required methods
fn send(
&self,
request: HttpRequest,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, Error>> + Send + '_>>;
fn open_stream(
&self,
request: HttpRequest,
idle_timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<(HttpResponse, Box<dyn ChunkSource>), Error>> + Send + '_>>;
}Expand description
The seam. Production and simulated transports implement this.
Required Methods§
Sourcefn send(
&self,
request: HttpRequest,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, Error>> + Send + '_>>
fn send( &self, request: HttpRequest, ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, Error>> + Send + '_>>
Sends one request and collects the whole body, whatever the status.
Deliberately does not fail on a status: a conformance suite asserts on 401 and 409 as expected outcomes, and a client that could only reach them through an error would be a client that cannot test the protocol.
Sourcefn open_stream(
&self,
request: HttpRequest,
idle_timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<(HttpResponse, Box<dyn ChunkSource>), Error>> + Send + '_>>
fn open_stream( &self, request: HttpRequest, idle_timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<(HttpResponse, Box<dyn ChunkSource>), Error>> + Send + '_>>
Opens a streaming response, reading the status before any body byte.
Status first so a 404 on an unknown exec id surfaces as NotFound rather than
as an empty stream. idle_timeout bounds silence rather than duration: an SSE
body is idle by design between chunks, so the useful bound is how long a gap may
last. Without one, a half-open connection — the failure a NAT or proxy timeout
produces, where no FIN ever arrives — hangs forever and the reconnect logic
never runs.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".