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
k-nasa e3bf89fc05 $cargo fmt 5 years ago
..
a-chat $cargo fmt 5 years ago
README.md add remaining examples 5 years ago
hello-world.rs remove async_await feature gate 5 years ago
line-count.rs remove async_await feature gate 5 years ago
list-dir.rs Clean up the fs module and a few other places 5 years ago
logging.rs remove async_await feature gate 5 years ago
print-file.rs fix test code 5 years ago
socket-timeouts.rs add remaining examples 5 years ago
stdin-echo.rs $cargo fmt 5 years ago
stdin-timeout.rs fix test code 5 years ago
surf-web.rs Enable surf example 5 years ago
task-local.rs remove async_await feature gate 5 years ago
task-name.rs remove async_await feature gate 5 years ago
tcp-client.rs remove async_await feature gate 5 years ago
tcp-echo.rs Implement Clone for TcpStream (#689) 5 years ago
tcp-ipv4-and-6-echo.rs Implement Clone for TcpStream (#689) 5 years ago
udp-client.rs remove async_await feature gate 5 years ago
udp-echo.rs remove async_await feature gate 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