#stdin #async-io #input #io #async #tokio

async-stdin

Asynchronously read from stdin

2 releases

0.3.1 Mar 28, 2023
0.3.0 Mar 28, 2023
0.2.0 Aug 30, 2020
0.1.0 Jun 7, 2020

#1295 in Asynchronous

Download history 1222/week @ 2024-03-14 2206/week @ 2024-03-21 3030/week @ 2024-03-28 1991/week @ 2024-04-04 3141/week @ 2024-04-11 2625/week @ 2024-04-18 2995/week @ 2024-04-25 2633/week @ 2024-05-02 2943/week @ 2024-05-09 2353/week @ 2024-05-16 2391/week @ 2024-05-23 2465/week @ 2024-05-30 2982/week @ 2024-06-06 2801/week @ 2024-06-13 2236/week @ 2024-06-20 1354/week @ 2024-06-27

9,984 downloads per month
Used in tokio-utils

MIT license

5KB

Async-Stdin

github crates.io docs.rs build status

Read from stdin over a Tokio channel

This is useful for interactive programs that read from stdin while waiting for other events to occur.

Usage

Add this to your Cargo.toml:

[dependencies]
async-stdin = "0.3.1"

You can read from stdin like so:

use async_stdin::recv_from_stdin;

#[tokio::main]
async fn main() {
    let mut rx = recv_from_stdin(10);
    while let Some(s) = rx.recv().await {
        println!("Received: {}", s);
    }
}

Dependencies

~2–3MB
~46K SLoC