#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

#1158 in Asynchronous

Download history 23/week @ 2023-12-16 19/week @ 2023-12-23 38/week @ 2023-12-30 76/week @ 2024-01-06 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 2462/week @ 2024-03-23 2081/week @ 2024-03-30

7,561 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