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

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

#2242 in Asynchronous

Download history 1763/week @ 2024-11-17 1816/week @ 2024-11-24 2460/week @ 2024-12-01 1865/week @ 2024-12-08 1929/week @ 2024-12-15 900/week @ 2024-12-22 1775/week @ 2024-12-29 1412/week @ 2025-01-05 2531/week @ 2025-01-12 2565/week @ 2025-01-19 2866/week @ 2025-01-26 2375/week @ 2025-02-02 3871/week @ 2025-02-09 2073/week @ 2025-02-16 3937/week @ 2025-02-23 2287/week @ 2025-03-02

12,324 downloads per month
Used in 3 crates (2 directly)

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–8MB
~47K SLoC