pub struct LoopbackClientEnd { /* private fields */ }Expand description
The client half of a loopback duplex: the end an embedded caller holds.
Reads BLOCK (with an optional deadline), mirroring the SDK’s socket
connection, whose reads are bounded by set_read_timeout and whose caller
reads both WouldBlock and TimedOut as the same “no bytes in the window”
answer. Writes never block: a full ring answers WouldBlock, exactly as a
full socket send buffer does.
Implementations§
Source§impl LoopbackClientEnd
impl LoopbackClientEnd
Sourcepub fn readable_bytes(&self) -> usize
pub fn readable_bytes(&self) -> usize
Bytes already waiting for this end, consuming none of them.
Sourcepub fn read_timeout(
&mut self,
buf: &mut [u8],
timeout: Option<Duration>,
) -> Result<usize>
pub fn read_timeout( &mut self, buf: &mut [u8], timeout: Option<Duration>, ) -> Result<usize>
Reads into buf, parking until bytes arrive, the server end is
dropped, or timeout elapses. None parks without a deadline.
Ok(0) is end of file: the server end is gone and its ring is drained.
§Errors
TimedOut when the window closes with no bytes and a live server end.
The SDK’s socket path reads WouldBlock and TimedOut identically, so
either satisfies its contract; TimedOut is the one that names what
happened.
Sourcepub fn write_timeout(
&mut self,
buf: &[u8],
timeout: Option<Duration>,
) -> Result<usize>
pub fn write_timeout( &mut self, buf: &[u8], timeout: Option<Duration>, ) -> Result<usize>
Writes from buf, parking until ring space appears, the server end is
dropped, or timeout elapses. None parks without a deadline. Returns
the accepted byte count, which may be short of buf.len().
This is the write-side twin of Self::read_timeout, and the socket it
stands in for is why it exists. A blocking TcpStream with a write
timeout BLOCKS while the kernel send buffer is full and fails only when
the window closes, so write_all over a socket makes progress across a
slow reader. Write::write on this end never blocks — a full ring
answers WouldBlock at once, which io::Write::write_all reads as a
hard failure — so a client driving the non-blocking half would see a
backpressure semantics no other mount has. Both halves are kept: the
non-blocking one is what the server end and the outbound budget want,
this one is what a client’s write_all equivalent wants.
§Errors
BrokenPipe when the server end has been dropped; TimedOut when the
window closes with the ring still full.
Trait Implementations§
Source§impl Debug for LoopbackClientEnd
impl Debug for LoopbackClientEnd
Source§impl Drop for LoopbackClientEnd
impl Drop for LoopbackClientEnd
Source§impl Read for LoopbackClientEnd
impl Read for LoopbackClientEnd
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Blocks without a deadline. Callers that need one use
LoopbackClientEnd::read_timeout.
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_, u8>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_, u8>) -> Result<(), Error>
read_buf)Source§fn read_buf_exact(
&mut self,
cursor: BorrowedCursor<'_, u8>,
) -> Result<(), Error>
fn read_buf_exact( &mut self, cursor: BorrowedCursor<'_, u8>, ) -> Result<(), Error>
read_buf)cursor. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read. Read more1.0.0 · Source§fn chain<R>(self, next: R) -> Chain<Self, R> ⓘ
fn chain<R>(self, next: R) -> Chain<Self, R> ⓘ
1.0.0 · Source§fn take(self, limit: u64) -> Take<Self> ⓘwhere
Self: Sized,
fn take(self, limit: u64) -> Take<Self> ⓘwhere
Self: Sized,
limit bytes from it. Read moreSource§fn read_array<const N: usize>(&mut self) -> Result<[u8; N], Error>where
Self: Sized,
fn read_array<const N: usize>(&mut self) -> Result<[u8; N], Error>where
Self: Sized,
read_array)Source§impl Write for LoopbackClientEnd
impl Write for LoopbackClientEnd
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Nothing buffers behind the ring, so a flush has nothing to push.
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)