A Future represents an asynchronous computation whose output is available later. An async function or block returns a future, not its eventual value. Futures are lazy: creating one does not run its body. Await it in an async context or spawn it on a runtime to make progress. section 8.3 section 8.4
Rust supplies the Future trait, async, and .await, but does not prescribe a runtime. Tokio supplies an executor and scheduler; #[tokio::main] starts the runtime for an async main function. Prefer async and .await over polling futures directly unless an interface requires it. section 8.1 section 8.3.1 section 8.4
pub trait Future {
type Output;
fn poll(self: Pin<&mut Self>, cx: &mut Context<‘_>) -> Poll<Self::Output>;
}
The trait signature exposes the implementation boundary: poll receives a pinned mutable reference and a context, then returns Poll<Self::Output>. An awaited future is polled through this interface. section 8.6 section 8.4
Await, discard, or spawn
In an async main function, `async { println!("first"); }.await` runs before the next statement. Assigning an async block to `_future` without awaiting or spawning it never runs its body. `tokio::task::spawn(async { ... })` schedules a task, but dropping its join handle and exiting does not guarantee that it finishes; await the handle when completion matters. section 8.4
Returning a future through a trait interface requires more care than writing an async function. A boxed `dyn Future` alone can fail at `.await` because it is not `Unpin`; returning `Pin<Box<dyn Future<Output = T>>>` and constructing it with `Box::pin(async { ... })` addresses that error. Borrowed inputs may also require an explicit lifetime on the returned future, while tasks that must cross threads may require `Send`. section 8.6
Keep blocking calls off the async scheduler. For synchronous work that must run inside an async workflow, `tokio::task::spawn_blocking` runs the function on Tokio-managed blocking threads and returns an awaitable future. For independent async work, `tokio::join!` or `tokio::select!` provides explicit concurrency; spawning tasks can also introduce parallelism. section 8.7 section 8.11







