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§
- Clonable
Stdin - A clonable
ThreadedStdout
wrapper based onRc<RefCell<ThreadedStdout>>
If you needSend
, use SendableStdout - Clonable
Stdout - A clonable
ThreadedStdout
wrapper based onRc<RefCell<ThreadedStdout>>
If you needSend
, use SendableStdout - Sendable
Stdin - A sendable and clonable ThreadedStdin wrapper based on
Arc<Mutex<ThreadedStdin>>
- Sendable
Stdin Guard - Result of
SendableStdin::lock
orSendableStdin::try_lock
- Sendable
Stdout - A sendable and clonable ThreadedStdout wrapper based on
Arc<Mutex<ThreadedStdout>>
- Sendable
Stdout Guard - Result of
SendableStdout::lock
orSendableStdout::try_lock
- Threaded
Stdin - Asynchronous stdin
- Threaded
Stdout - Asynchronous stdout
Functions§
- stderr
- Constructor for the
ThreadedStderr
- stdin
- Constructor for the
ThreadedStdin
- stdout
- Constructor for the
ThreadedStdout
Type Aliases§
- Clonable
Stderr - Alias for ClonableStdout to avoid confusion of ClonableStdout being used for stderr.
- Sendable
Stderr - Alias for SendableStdout to avoid confusion of SendableStdout being used for stderr.
- Sendable
Stderr Guard - Result of
SendableStderr::lock
orSendableStderr::try_lock
- Threaded
Stderr - Asynchronous stderr