#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

#2081 in Asynchronous

Download history 2419/week @ 2024-07-23 2134/week @ 2024-07-30 2780/week @ 2024-08-06 2650/week @ 2024-08-13 2074/week @ 2024-08-20 1974/week @ 2024-08-27 1392/week @ 2024-09-03 3138/week @ 2024-09-10 1574/week @ 2024-09-17 3313/week @ 2024-09-24 1972/week @ 2024-10-01 2396/week @ 2024-10-08 1680/week @ 2024-10-15 4028/week @ 2024-10-22 1934/week @ 2024-10-29 1948/week @ 2024-11-05

9,905 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–7.5MB
~47K SLoC