Struct SimplexStream

struct SimplexStream { ... }

A unidirectional pipe to read and write bytes in memory.

It can be constructed by simplex function which will create a pair of reader and writer or by calling SimplexStream::new_unsplit that will create a handle for both reading and writing.

Example

# async fn ex() -> std::io::Result<()> {
# use tokio::io::{AsyncReadExt, AsyncWriteExt};
let (mut receiver, mut sender) = tokio::io::simplex(64);

sender.write_all(b"ping").await?;

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

Implementations

impl SimplexStream

fn new_unsplit(max_buf_size: usize) -> SimplexStream

Creates unidirectional buffer that acts like in memory pipe. To create split version with separate reader and writer you can use simplex function.

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

impl AsyncRead for SimplexStream

fn poll_read(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>) -> Poll<Result<()>>

impl AsyncWrite for SimplexStream

fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>>
fn poll_write_vectored(self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>]) -> Poll<Result<usize, Error>>
fn is_write_vectored(self: &Self) -> bool
fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<()>>
fn poll_shutdown(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<()>>

impl Debug for SimplexStream

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Freeze for SimplexStream

impl RefUnwindSafe for SimplexStream

impl Send for SimplexStream

impl Sync for SimplexStream

impl Unpin for SimplexStream

impl UnsafeUnpin for SimplexStream

impl UnwindSafe for SimplexStream

impl<R> AsyncReadExt for SimplexStream

impl<T> Any for SimplexStream

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for SimplexStream

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for SimplexStream

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> From for SimplexStream

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for SimplexStream

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for SimplexStream

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for SimplexStream

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>

impl<W> AsyncWriteExt for SimplexStream