#stdio #tokio #async-io #stdin #stdout #buffering #little

tokio-stdin-stdout

Thread- and future::sync::mpsc-based AsyncRead/AsyncWrite stdin/stdout with little buffering

6 releases

Uses old Rust 2015

0.1.5 Oct 31, 2018
0.1.4 Aug 15, 2018
0.1.3 Jun 25, 2018
0.1.1 Oct 12, 2017

#724 in Asynchronous

Download history 322/week @ 2024-01-07 332/week @ 2024-01-14 310/week @ 2024-01-21 404/week @ 2024-01-28 424/week @ 2024-02-04 486/week @ 2024-02-11 459/week @ 2024-02-18 443/week @ 2024-02-25 363/week @ 2024-03-03 331/week @ 2024-03-10 360/week @ 2024-03-17 486/week @ 2024-03-24 538/week @ 2024-03-31 341/week @ 2024-04-07 493/week @ 2024-04-14 361/week @ 2024-04-21

1,762 downloads per month
Used in 10 crates (9 directly)

MIT/Apache

23KB
410 lines

tokio-stdin-stdout

AsyncRead/AsyncWrite stdin/stdout for Tokio

Documentation - more description there

Example

let mut core = tokio_core::reactor::Core::new()?;

let stdin = tokio_stdin_stdout::stdin(0);
let stdout = tokio_stdin_stdout::stdout(0);

core.run(tokio_io::io::copy(stdin, stdout))?;

Additional examples

  1. loop.rs - Write hello ten times
  2. line-by-line.rs - Convert all input text to ASCII upper case, line by line. This example also demonstrates usage of tokio-codec and various modes of starting Tokio programs (multithreaded, singlethreaded).

async fn demo

Not much related to tokio-stdin-stdout, but there are some async fn examples runnable by cargo script.

They require nightly Rust.

Alternatives

  1. tokio-stdin no AsyncRead, only stdin, byte by byte
  2. tokio-file-unix - better, but only Unix

Dependencies

~605KB
~11K SLoC