Skip to main content

timeout_with

Function timeout_with 

Source
pub async fn timeout_with<T, E, F>(
    kind: TimeoutKind,
    duration: Duration,
    fut: F,
) -> Result<T, Error>
where F: Future<Output = Result<T, E>>, Error: From<E>,
Expand description

Run fut under a tokio timeout and translate the elapsed case into a named TimeoutKind. Replaces the previous From<Elapsed> impl so every call site spells out which stage owns the timeout.

§Errors

On expiry returns Error::timeout; otherwise propagates fut’s own Result.