Expand description
A support crate for The Rust Programming Language.
This crate mostly just re-exports items from other crates. It exists for two main reasons:
-
So that as you read along in The Rust Programming Language, you can add just one dependency, rather than however many we end up with, and likewise use only one set of imports.
-
So that we can more easily guarantee it keeps building and working. Since we control the contents of this crate and when it changes, readers will never be broken by upstream changes, e.g. if Tokio does a breaking 2.0 release at some point.
Macros§
- join
- Polls multiple futures simultaneously, returning a tuple of all results once complete.
Structs§
- Html
- A thin wrapper around
scraper::Htmlto make the demos in The Rust Programming Language substantially nicer to use. - Interval
Stream - A wrapper around
Intervalthat implementsStream. - Join
Handle - An owned permission to join on a task (await its termination).
- Receiver
- Receive values from the associated
UnboundedSender. - Receiver
Stream - A wrapper around
tokio::sync::mpsc::UnboundedReceiverthat implementsStream. - Response
- A thin wrapper around
reqwest::Responseto make the demos in The Rust Programming Language substantially nicer to use. - Runtime
- The Tokio runtime.
- Sender
- Send values to the associated
UnboundedReceiver.
Enums§
- Either
- Combines two different futures, streams, or sinks having the same associated types into a single type.
Traits§
- Stream
- A stream of values produced asynchronously.
- Stream
Ext - An extension trait for the
Streamtrait that provides a variety of convenient combinator functions.
Functions§
- block_
on - Run a single future to completion on a bespoke Tokio
Runtime. - channel
- Creates an unbounded mpsc channel for communicating between asynchronous tasks without backpressure.
- get
- Fetch data from a URL. For more convenient use in The Rust Programming
Language, panics instead of returning a
Resultif the request fails. - interval
- Creates new
Intervalthat yields with interval ofperiod. The first tick completes immediately. The defaultMissedTickBehaviorisBurst, but this can be configured by callingset_missed_tick_behavior. - join
- Joins the result of two futures, waiting for them both to complete.
- join3
- Same as
join, but with more futures. - join_
all - Creates a future which represents a collection of the outputs of the futures given.
- race
- This function has been renamed to
select; please see its documentation. This function remains to maintain compatibility with the online versions of the book that use the namerace. - read_
to_ string - Creates a future which will open a file for reading and read the entire contents into a string and return said string.
- run
- This function has been renamed to
block_on; please see its documentation. This function remains to maintain compatibility with the online versions of the book that use the namerun. - select
- Run two futures, taking whichever finishes first and canceling the other.
- sleep
- Waits until
durationhas elapsed. - spawn_
task - Spawns a new asynchronous task, returning a
JoinHandlefor it. - stream_
from_ iter - Converts an
Iteratorinto aStreamwhich is always ready to yield the next value. - yield_
now - Yields execution back to the Tokio runtime.