Crate trpl

Source
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:

  1. 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.

  2. 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.
IntervalStream
A wrapper around Interval that implements Stream.
JoinHandle
An owned permission to join on a task (await its termination).
Receiver
Receive values from the associated UnboundedSender.
ReceiverStream
A wrapper around tokio::sync::mpsc::UnboundedReceiver that implements Stream.
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.
StreamExt
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 of period. The first tick completes immediately. The default MissedTickBehavior is Burst, but this can be configured by calling set_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 a Stream which is always ready to yield the next value.
yield_now
Yields execution back to the Tokio runtime.