Skip to content

Files

Latest commit

Aug 21, 2024
57eafb4 · Aug 21, 2024

History

History

examples

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Aug 21, 2024
Jun 2, 2022
Aug 21, 2019
Aug 21, 2019
Sep 13, 2019
Aug 19, 2020
Mar 12, 2020
Sep 27, 2019
Mar 12, 2020
Mar 12, 2020
Oct 20, 2020
Aug 21, 2019
Aug 21, 2019
Aug 21, 2019
Jan 28, 2020
Jan 28, 2020
Aug 21, 2019
Aug 21, 2019

Examples

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

Spawns a task that says hello.

cargo run --example hello-world

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

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

Lists files in a directory given as an argument.

cargo run --example list-dir -- .

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

cargo run --example logging

Prints a file given as an argument to stdout.

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

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

cargo run --example socket-timeouts

Echoes lines read on stdin to stdout.

cargo run --example stdin-echo

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

cargo run --example stdin-timeout

Sends an HTTP request to the Rust website.

cargo run --example surf-web

Creates a task-local value.

cargo run --example task-local

Spawns a named task that prints its name.

cargo run --example task-name

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

Start the echo server:

cargo run --example tcp-echo

Make requests by running the client example:

cargo run --example tcp-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 server.

Start the echo server:

cargo run --example udp-echo

Make requests by running the client example:

cargo run --example udp-client