Function safina_timer::with_timeout[][src]

pub async fn with_timeout<R, Fut: Future<Output = R> + Send + 'static>(
    inner: Fut,
    duration: Duration
) -> Result<R, DeadlineExceeded>

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.