pub async fn with_timeout<Fut: Future>(
    inner: Fut,
    duration: Duration
) -> Result<Fut::Output, DeadlineExceeded>
Expand description

Awaits inner, but returns DeadlineExceeded after duration time from now.

First moves inner to the heap, to make it Unpin. Use DeadlineFuture::new to avoid allocating on the heap.

Errors

Returns Err(DeadlineExceeded) if duration passes before inner completes.

Panics

Panics if start_timer_thread() has not been called. If you need to handle this error, use DeadlineFuture::new.