Function safina::with_deadline[][src]

pub async fn with_deadline<R, Fut>(
    inner: Fut,
    deadline: Instant
) -> Result<R, DeadlineExceeded> where
    Fut: 'static + Future<Output = R> + Send

Awaits inner, but returns DeadlineExceeded after deadline.

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

Errors

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

Panics

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