Skip to main content

with_recovery

Function with_recovery 

pub fn with_recovery<B, E, R, F>(
    application_rule: R,
    is_rejection: F,
) -> impl RetryRule<Request<RetryBody>, Response<B>, E> + Clone
where B: Send + 'static, E: Send + Sync + 'static, R: RetryRule<Request<RetryBody>, Response<B>, E>, F: Fn(&E) -> bool + Send + Sync + 'static,
Available on crate features http and std only.
Expand description

Handle 425 and typed TLS early rejection before an application’s retry rule.

The classifier keeps the caller’s error type unchanged. For example, |error: &BoxError| is_early_data_rejected(error.as_ref()) works with boxed errors; concrete errors can be passed directly to the chain walker.

Recovery requires a replayable safe, empty request and actual transport evidence. It writes ForbidEarlyData into the policy’s caller store before requesting one confirmed retry. A repeated 425 or TLS rejection is terminal. Forwarded marked requests never recover a 425 locally; actual upstream TLS rejection can still be recovered. DoNotRetry always takes precedence.

Compose application rules here instead of nesting separate Retry owners: each owner has its own attempt forks. Ordinary non-425 responses and other errors delegate to the application rule, whose retry budget still applies.