zng::task

Function with_deadline

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

Add a deadline to a future.

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