[−][src]Function safina::with_timeout
pub async fn with_timeout<R, Fut>(
inner: Fut,
duration: Duration
) -> Result<R, DeadlineExceeded> where
Fut: 'static + Send + Future<Output = R>,
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.
Safety
Panics if start_timer_thread()
has not been called.
If you need to handle this error, use
DeadlineFuture::new
.