#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

#2138 in Asynchronous

Download history 2396/week @ 2024-10-08 1680/week @ 2024-10-15 4028/week @ 2024-10-22 1942/week @ 2024-10-29 2009/week @ 2024-11-05 3024/week @ 2024-11-12 1949/week @ 2024-11-19 1660/week @ 2024-11-26 2614/week @ 2024-12-03 1650/week @ 2024-12-10 1974/week @ 2024-12-17 819/week @ 2024-12-24 1784/week @ 2024-12-31 1516/week @ 2025-01-07 2687/week @ 2025-01-14 2129/week @ 2025-01-21

8,300 downloads per month
Used in 2 crates

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