Function simplex

fn simplex(max_buf_size: usize) -> (ReadHalf<SimplexStream>, WriteHalf<SimplexStream>)

Creates unidirectional buffer that acts like in memory pipe.

The max_buf_size argument is the maximum amount of bytes that can be written to a buffer before the it returns Poll::Pending.

Unify reader and writer

The reader and writer half can be unified into a single structure of SimplexStream that supports both reading and writing or the SimplexStream can be already created as unified structure using [SimplexStream::new_unsplit()].

# async fn ex() -> std::io::Result<()> {
# use tokio::io::{AsyncReadExt, AsyncWriteExt};
let (reader, writer) = tokio::io::simplex(64);
let mut simplex_stream = reader.unsplit(writer);
simplex_stream.write_all(b"hello").await?;

let mut buf = [0u8; 5];
simplex_stream.read_exact(&mut buf).await?;
assert_eq!(&buf, b"hello");
# Ok(())
# }