pub fn with_timeout_state<S, F>(
duration: Duration,
handler: F,
) -> impl Fn(&Request, &PathParams, &ConnectionInfo, &S) -> Response + Send + Sync + 'staticExpand description
Wraps an AppWithState<S> handler (which additionally receives &S) so
it must complete within duration or the caller gets 504 Gateway Timeout instead of waiting further.
Requires S: Clone — the wrapped call runs on a background thread that
needs its own owned copy of the state, since the handler signature only
gives a borrowed &S. Most AppWithState state types hold their own
data behind Arc internally and are cheap to #[derive(Clone)]; if
yours isn’t, wrap the whole app with TimeoutLayer instead, or switch
the route to AsyncAppWithState and use with_timeout_async, which
needs no Clone bound at all.