You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
async-std/examples/README.md

3.6 KiB

Examples

This directory contains example code that makes use of async-std, each of which can be run from the command line.

Hello World

Spawns a task that says hello.

cargo run --example hello-world
Line Count

Counts the number of lines in a file given as an argument.

cargo run --example line-count -- ./Cargo.toml
List Dir

Lists files in a directory given as an argument.

cargo run --example list-dir -- .
Logging

Prints the runtime's execution log on the standard output.

cargo run --example logging
Print File

Prints a file given as an argument to stdout.

cargo run --example print-file ./Cargo.toml
Socket Timeouts

Prints response of GET request made to TCP server with 5 second socket timeout

cargo run --example socket-timeouts
Stdin Echo

Echoes lines read on stdin to stdout.

cargo run --example stdin-echo
Stdin Timeout

Reads a line from stdin, or exits with an error if nothing is read in 5 seconds.

cargo run --example stdin-timeout
Surf Web

Sends an HTTP request to the Rust website.

cargo run --example surf-web
Task Local

Creates a task-local value.

cargo run --example task-local
Task Name

Spawns a named task that prints its name.

cargo run --example task-name
TCP Client

Connects to Localhost over TCP.

First, start the echo server:

cargo run --example tcp-echo

Then run the client:

cargo run --example tcp-client
TCP Echo

TCP echo server.

Start the echo server:

cargo run --example tcp-echo

Make requests by running the client example:

cargo run --example tcp-client
UDP Client

Connects to Localhost over UDP.

First, start the echo server:

cargo run --example udp-echo

Then run the client:

cargo run --example udp-client
UDP Echo

UDP echo server.

Start the echo server:

cargo run --example udp-echo

Make requests by running the client example:

cargo run --example udp-client