Skip to main content

Module interim

Module interim 

Source
Expand description

Per-exchange interim-response hooks, independent of message heads and bodies.

InterimResponses supplies per-exchange send and receive hooks using the same ResponseMetadata as final responses. Its handler can be a protocol writer or an async observer. It validates interim status codes, excludes final 101, and stops delivery after finish or a failed or abandoned started send. Drivers call finish when committing or receiving the final metadata.

use base_http::{InterimResponses, ResponseMetadata, Status};
use base_scheduler::Cancellation;
use std::convert::Infallible;

let mut interim = InterimResponses::new(|head: ResponseMetadata| async move {
    assert_eq!(head.status, Status::EARLY_HINTS);
    Ok::<_, Infallible>(())
});
futures_lite::future::block_on(interim.send_interim_response(
    ResponseMetadata::new(Status::EARLY_HINTS), &Cancellation::never(),
))?;
interim.finish();

Structs§

InterimResponses
Explicit server responder/client observer state for one exchange.

Enums§

InterimError
An interim response failure. Handler is transparent: it displays the handler’s error and reports that error’s source.

Traits§

InterimHandler
A protocol writer or client observer for an interim response head.