Expand description

Combine a reader + writer into a duplex of Read + Write.

This is useful when you need a reader + writer, but it doesn’t come neatly pre-packaged. This allows wiring it together with minimal effort. See also: io::empty, io::sink.

Examples

Read a line from stdin, and write it to stdout. All from the same stdio object:

use async_std::io::{self, BufReader, prelude::*};
use duplexify::Duplex;

// Create a reader and writer, and merge them into a single "duplex".
let stdin = BufReader::new(io::stdin());
let stdout = io::stdout();
let mut stdio = Duplex::new(stdin, stdout);

// We can now read + write from and to the duplex.
let mut line = String::new();
stdio.read_line(&mut line).await?;
stdio.write_all(&line.as_bytes()).await?;

Structs

Combine a reader + writer into a duplex of Read + Write.