Trait completion_core::CompletionFuture [−][src]
A Future
that must be polled to completion.
All types that implement Future
should also implement this.
A completion future has three states: running, cancelling and complete. Futures initially start
out in the running state. To progress the running state, users will call poll
, which either
returns Poll::Pending
to continue the running state or Poll::Ready
to return a value and
reach the complete state.
At any time during the running state, users may call poll_cancel
to initiate the cancelling
state. During this state, only poll_cancel
should be called, and it can return
Poll::Pending
to continue the cancelling state or Poll::Ready
(())
to reach the
complete state.
Once the complete state has been reached, either by regular completion or after cancellation,
neither poll
nor poll_cancel
should be called again.
A violation of these rules can cause unexpected behaviour: the future may panic, block forever or return unexpected results. However, it must never cause undefined behaviour.
Associated Types
Loading content...Required methods
unsafe fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>
[src]
Attempt to resolve the future to a final value, registering the current task for wakeup if the value is not yet available.
This function should only be called when the future is in the running state.
Safety
Once this function has been called and the type does not also implement Future
, the user
must not drop or forget the future until it it has returned Poll::Ready
or panicked.
unsafe fn poll_cancel(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()>
[src]
Attempt to cancel the future, registering the current task for wakeup if has not finished cancelling yet.
This function should only be called from the running state or in the cancelling state. Once
this function returns Poll::Ready
, the future should be considered complete and should
not be polled again.
Note that this may be called before poll
has been called for the first
time.
Safety
Once this function has been called and the type does not also implement Future
, the user
must not drop or forget the future until it has returned Poll::Ready
or panicked.
Implementations on Foreign Types
impl<F: CompletionFuture + Unpin + ?Sized> CompletionFuture for &mut F
[src]
type Output = F::Output
unsafe fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>
[src]
unsafe fn poll_cancel(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()>
[src]
impl<F: CompletionFuture + Unpin + ?Sized> CompletionFuture for Box<F>
[src]
type Output = F::Output
unsafe fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>
[src]
unsafe fn poll_cancel(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()>
[src]
impl<P> CompletionFuture for Pin<P> where
P: Unpin + DerefMut,
P::Target: CompletionFuture,
[src]
P: Unpin + DerefMut,
P::Target: CompletionFuture,
type Output = <P::Target as CompletionFuture>::Output
unsafe fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>
[src]
unsafe fn poll_cancel(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()>
[src]
impl<F: CompletionFuture> CompletionFuture for AssertUnwindSafe<F>
[src]
type Output = F::Output
unsafe fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>
[src]
unsafe fn poll_cancel(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()>
[src]
impl<T> CompletionFuture for Pending<T> where
Self: RegularFuture,
[src]
Self: RegularFuture,
type Output = <Pending<T> as RegularFuture>::Output
unsafe fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>
[src]
unsafe fn poll_cancel(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()>
[src]
impl<T> CompletionFuture for Ready<T> where
Self: RegularFuture,
[src]
Self: RegularFuture,