Skip to main content

within_bounds

Function within_bounds 

Source
pub async fn within_bounds<F: Future>(
    bounds: RequestBounds,
    progress: &ExchangeProgress,
    exchange: F,
) -> Result<F::Output, RequestCut>
Expand description

Drive exchange while progress keeps moving inside bounds; cut it when it does not.

The deadline moves with the progress, so the watcher sleeps to the current deadline, and on waking re-reads it: progress since pushes it out, and none means the cut. Nothing here bounds the exchange’s total duration.

On a cut exchange is dropped, and with it the connection: on HTTP/1.1 it closes, on HTTP/2 the stream resets (networking doc, HTTP Transport).

§Errors

The RequestCut that ended it.