Function safina::with_deadline
source · [−]pub async fn with_deadline<R, Fut>(
inner: Fut,
deadline: Instant
) -> Result<R, DeadlineExceeded> where
Fut: 'static + Future<Output = R> + Send,
Expand description
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
.