[][src]Crate tokio_stdin_stdout

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

ClonableStdin

A clonable ThreadedStdout wrapper based on Rc<RefCell<ThreadedStdout>> If you need Send, use SendableStdout

ClonableStdout

A clonable ThreadedStdout wrapper based on Rc<RefCell<ThreadedStdout>> If you need Send, use SendableStdout

SendableStdin

A sendable and clonable ThreadedStdin wrapper based on Arc<Mutex<ThreadedStdin>>

SendableStdinGuard

Result of SendableStdin::lock or SendableStdin::try_lock

SendableStdout

A sendable and clonable ThreadedStdout wrapper based on Arc<Mutex<ThreadedStdout>>

SendableStdoutGuard

Result of SendableStdout::lock or SendableStdout::try_lock

ThreadedStdin

Asynchronous stdin

ThreadedStdout

Asynchronous stdout

Functions

stderr

Constructor for the ThreadedStderr

stdin

Constructor for the ThreadedStdin

stdout

Constructor for the ThreadedStdout

Type Definitions

ClonableStderr

Alias for ClonableStdout to avoid confusion of ClonableStdout being used for stderr.

SendableStderr

Alias for SendableStdout to avoid confusion of SendableStdout being used for stderr.

SendableStderrGuard

Result of SendableStderr::lock or SendableStderr::try_lock

ThreadedStderr

Asynchronous stderr