Skip to main content

with_timeout_async

Function with_timeout_async 

Source
pub fn with_timeout_async<S, F, Fut>(
    duration: Duration,
    handler: F,
) -> impl Fn(Request, PathParams, ConnectionInfo, Arc<S>) -> Pin<Box<dyn Future<Output = Response> + Send + 'static>> + Send + Sync + 'static
where S: Send + Sync + 'static, F: Fn(Request, PathParams, ConnectionInfo, Arc<S>) -> Fut + Send + Sync + 'static, Fut: Future<Output = Response> + Send + 'static,
Expand description

Wraps an AsyncAppWithState<S> handler so its future is dropped — genuinely cancelled at its next .await point — if it doesn’t resolve within duration. Backed by tokio::time::timeout; requires the http2 feature. No Clone bound on S: AsyncAppWithState already passes state as an owned Arc<S>.