Struct DuplexStream
struct DuplexStream { ... }
A bidirectional pipe to read and write bytes in memory.
A pair of DuplexStreams are created together, and they act as a "channel"
that can be used as in-memory IO types. Writing to one of the pairs will
allow that data to be read from the other, and vice versa.
Closing a DuplexStream
If one end of the DuplexStream channel is dropped, any pending reads on
the other side will continue to read data until the buffer is drained, then
they will signal EOF by returning 0 bytes. Any writes to the other side,
including pending ones (that are waiting for free space in the buffer) will
return Err(BrokenPipe) immediately.
Example
# async
Implementations
impl AsyncRead for DuplexStream
fn poll_read(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>) -> Poll<Result<()>>
impl AsyncWrite for DuplexStream
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) -> boolfn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
impl Debug for DuplexStream
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Drop for DuplexStream
fn drop(self: &mut Self)
impl Freeze for DuplexStream
impl RefUnwindSafe for DuplexStream
impl Send for DuplexStream
impl Sync for DuplexStream
impl Unpin for DuplexStream
impl UnsafeUnpin for DuplexStream
impl UnwindSafe for DuplexStream
impl<R> AsyncReadExt for DuplexStream
impl<T> Any for DuplexStream
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for DuplexStream
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for DuplexStream
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for DuplexStream
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for DuplexStream
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for DuplexStream
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for DuplexStream
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>