pub trait Future {
type Output;
// Required method
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>;
}
Expand description
A future represents an asynchronous computation obtained by use of async
.
A future is a value that might not have finished computing yet. This kind of “asynchronous value” makes it possible for a thread to continue doing useful work while it waits for the value to become available.
§The poll
method
The core method of future, poll
, attempts to resolve the future into a
final value. This method does not block if the value is not ready. Instead,
the current task is scheduled to be woken up when it’s possible to make
further progress by poll
ing again. The context
passed to the poll
method can provide a Waker
, which is a handle for waking up the current
task.
When using a future, you generally won’t call poll
directly, but instead
.await
the value.