zng_task

Function with_deadline

Source
pub async fn with_deadline<O, F: Future<Output = O>>(
    fut: impl IntoFuture<IntoFuture = F>,
    deadline: impl Into<Deadline>,
) -> Result<F::Output, DeadlineError>
Expand description

Add a deadline to a future.

Returns the fut output or DeadlineError if the deadline elapses first.