tree: 583010cd7913047bc2f8dc3e99e1bd7160c8a57f [path history] [tgz]
  1. a-chat/
  2. hello-world.rs
  3. line-count.rs
  4. list-dir.rs
  5. logging.rs
  6. print-file.rs
  7. README.md
  8. socket-timeouts.rs
  9. stdin-echo.rs
  10. stdin-timeout.rs
  11. surf-web.rs
  12. task-local.rs
  13. task-name.rs
  14. tcp-client.rs
  15. tcp-echo.rs
  16. tcp-ipv4-and-6-echo.rs
  17. udp-client.rs
  18. udp-echo.rs
third_party/rust_crates/vendor/async-std/examples/README.md

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