cc19592f80 | 5 years ago | |
---|---|---|
.. | ||
a-chat | 5 years ago | |
README.md | 5 years ago | |
hello-world.rs | 5 years ago | |
line-count.rs | 5 years ago | |
list-dir.rs | 5 years ago | |
logging.rs | 5 years ago | |
print-file.rs | 5 years ago | |
socket-timeouts.rs | 5 years ago | |
stdin-echo.rs | 5 years ago | |
stdin-timeout.rs | 5 years ago | |
surf-web.rs | 5 years ago | |
task-local.rs | 5 years ago | |
task-name.rs | 5 years ago | |
tcp-client.rs | 5 years ago | |
tcp-echo.rs | 5 years ago | |
tcp-ipv4-and-6-echo.rs | 5 years ago | |
udp-client.rs | 5 years ago | |
udp-echo.rs | 5 years ago |
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