Expand description

A bridge between [std::io::std{in,out}][1] and Future’s AsyncRead/AsyncWrite worlds. [1]:https://doc.rust-lang.org/std/io/fn.stdin.html

Example:

extern crate tokio_core;
extern crate tokio_io;
extern crate tokio_stdin_stdout;

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

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

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

It works by starting separate threads, which do actual synchronous I/O and communicating to the asynchronous world using future::sync::mpsc.

For Unix (Linux, OS X) better use tokio-file-unix.

Concerns:

  • stdin/stdout are not expected to be ever normally used after using functions from this crate
  • Allocation-heavy.
  • All errors collapsed to ErrorKind::Other (for stdout) or ErrorKind::BrokenPipe (for stdin)
  • Failure to write to stdout is only seen after attempting to send there about 3 more buffers.

Structs

A clonable ThreadedStdout wrapper based on Rc<RefCell<ThreadedStdout>> If you need Send, use SendableStdout
A clonable ThreadedStdout wrapper based on Rc<RefCell<ThreadedStdout>> If you need Send, use SendableStdout
A sendable and clonable ThreadedStdin wrapper based on Arc<Mutex<ThreadedStdin>>
Result of SendableStdin::lock or SendableStdin::try_lock
A sendable and clonable ThreadedStdout wrapper based on Arc<Mutex<ThreadedStdout>>
Result of SendableStdout::lock or SendableStdout::try_lock
Asynchronous stdin
Asynchronous stdout

Functions

Constructor for the ThreadedStderr
Constructor for the ThreadedStdin
Constructor for the ThreadedStdout

Type Definitions

Alias for ClonableStdout to avoid confusion of ClonableStdout being used for stderr.
Alias for SendableStdout to avoid confusion of SendableStdout being used for stderr.
Result of SendableStderr::lock or SendableStderr::try_lock
Asynchronous stderr