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

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

#1314 in Asynchronous

Download history 56/week @ 2024-01-13 158/week @ 2024-01-20 361/week @ 2024-01-27 343/week @ 2024-02-03 541/week @ 2024-02-10 563/week @ 2024-02-17 548/week @ 2024-02-24 861/week @ 2024-03-02 1002/week @ 2024-03-09 1919/week @ 2024-03-16 2461/week @ 2024-03-23 2406/week @ 2024-03-30 2544/week @ 2024-04-06 3064/week @ 2024-04-13 3054/week @ 2024-04-20 2050/week @ 2024-04-27

11,041 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