Crates.io | async-stdin |
lib.rs | async-stdin |
version | 0.3.1 |
source | src |
created_at | 2020-06-07 08:16:08.941699 |
updated_at | 2023-03-28 03:24:18.929494 |
description | Asynchronously read from stdin |
homepage | |
repository | |
max_upload_size | |
id | 250897 |
size | 14,776 |
Read from stdin over a Tokio channel
This is useful for interactive programs that read from stdin while waiting for other events to occur.
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);
}
}