3 releases
Uses old Rust 2015
0.1.2 | Jul 9, 2019 |
---|---|
0.1.1 | Jan 3, 2018 |
0.1.0 | Oct 1, 2017 |
#1171 in Concurrency
55 downloads per month
Used in stream-combinators
6KB
tokio-stdin
NOTE: This library is no longer necessary. As of tokio
0.1.6, it is now possible to read
from stdin without the overhead of spawning a separate thread with the tokio::io::stdin
function.
Read from stdin as a Tokio stream by spawning a separate thread.
extern crate futures;
extern crate tokio_stdin;
fn main() {
use futures::Stream;
tokio_stdin::spawn_stdin_stream_unbounded().wait();
}
As far as I know, this is currently the recommended way to do this. On Dec 29, 2016, alexcrichton commented:
In general for small CLI tools and such what you probably want to do is to use channels to communicate to foreign threads. You can have a thread per stdin/stdout/stderr with a
futures::sync::mpsc
that the main thread communicates with.
This crate locks stdin while it's running, so trying to read from stdin in another part of your code will probably cause a deadlock.
See the count_keys
example for a simple use of this.
License: MIT/Apache-2.0
Dependencies
~53KB