Struct safina::DeadlineFuture
source · [−]pub struct DeadlineFuture<R, Fut> where
Fut: 'static + Future<Output = R> + Send + Unpin, { /* private fields */ }
Expand description
A future wrapper that returns DeadlineExceeded
at a specified deadline.
It is returned by with_deadline
and with_timeout
.
Implementations
sourceimpl<R, Fut> DeadlineFuture<R, Fut> where
Fut: 'static + Future<Output = R> + Send + Unpin,
impl<R, Fut> DeadlineFuture<R, Fut> where
Fut: 'static + Future<Output = R> + Send + Unpin,
sourcepub fn new(inner: Fut, deadline: Instant) -> DeadlineFuture<R, Fut>ⓘNotable traits for DeadlineFuture<R, Fut>impl<R, Fut> Future for DeadlineFuture<R, Fut> where
Fut: 'static + Future<Output = R> + Send + Unpin, type Output = Result<R, DeadlineError>;
pub fn new(inner: Fut, deadline: Instant) -> DeadlineFuture<R, Fut>ⓘNotable traits for DeadlineFuture<R, Fut>impl<R, Fut> Future for DeadlineFuture<R, Fut> where
Fut: 'static + Future<Output = R> + Send + Unpin, type Output = Result<R, DeadlineError>;
Fut: 'static + Future<Output = R> + Send + Unpin, type Output = Result<R, DeadlineError>;
Makes a future that awaits inner
,
but returns DeadlineError
after deadline
.
Note that inner
must be
Unpin
.
Use std::boxed::Box::pin
to make it Unpin.
Or use pin_utils::pin_mut
to do it with unsafe code that does not allocate memory.
Trait Implementations
sourceimpl<R, Fut> Future for DeadlineFuture<R, Fut> where
Fut: 'static + Future<Output = R> + Send + Unpin,
impl<R, Fut> Future for DeadlineFuture<R, Fut> where
Fut: 'static + Future<Output = R> + Send + Unpin,
type Output = Result<R, DeadlineError>
type Output = Result<R, DeadlineError>
The type of value produced on completion.
sourcepub fn poll(
self: Pin<&mut DeadlineFuture<R, Fut>>,
cx: &mut Context<'_>
) -> Poll<<DeadlineFuture<R, Fut> as Future>::Output>
pub fn poll(
self: Pin<&mut DeadlineFuture<R, Fut>>,
cx: &mut Context<'_>
) -> Poll<<DeadlineFuture<R, Fut> as Future>::Output>
Attempt to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more
Auto Trait Implementations
impl<R, Fut> RefUnwindSafe for DeadlineFuture<R, Fut> where
Fut: RefUnwindSafe,
impl<R, Fut> Send for DeadlineFuture<R, Fut>
impl<R, Fut> Sync for DeadlineFuture<R, Fut> where
Fut: Sync,
impl<R, Fut> Unpin for DeadlineFuture<R, Fut>
impl<R, Fut> UnwindSafe for DeadlineFuture<R, Fut> where
Fut: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<F> IntoFuture for F where
F: Future,
impl<F> IntoFuture for F where
F: Future,
type Output = <F as Future>::Output
type Output = <F as Future>::Output
🔬 This is a nightly-only experimental API. (
into_future
)The output that the future will produce on completion.
type Future = F
type Future = F
🔬 This is a nightly-only experimental API. (
into_future
)Which kind of future are we turning this into?
sourcepub fn into_future(self) -> <F as IntoFuture>::Future
pub fn into_future(self) -> <F as IntoFuture>::Future
🔬 This is a nightly-only experimental API. (
into_future
)Creates a future from a value.