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