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::Html
to make the demos in The Rust Programming Language substantially nicer to use. - Interval
Stream - A wrapper around
Interval
that 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::UnboundedReceiver
that implementsStream
. - Response
- A thin wrapper around
reqwest::Response
to 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
Stream
trait that provides a variety of convenient combinator functions.
Functions§
- 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
Result
if the request fails. - interval
- Creates new
Interval
that yields with interval ofperiod
. The first tick completes immediately. The defaultMissedTickBehavior
isBurst
, 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
- Run two futures, taking whichever finishes first and canceling the other.
- 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
- Run a single future to completion on a bespoke Tokio
Runtime
. - sleep
- Waits until
duration
has elapsed. - spawn_
task - Spawns a new asynchronous task, returning a
JoinHandle
for it. - stream_
from_ iter - Converts an
Iterator
into aStream
which is always ready to yield the next value. - yield_
now - Yields execution back to the Tokio runtime.