pub struct ReadHalf { /* private fields */ }Expand description
The reading end of one side. Dropping it tells the peer’s writer that nothing more will be read.
Implementations§
Source§impl ReadHalf
impl ReadHalf
pub fn id(&self) -> StreamId
Sourcepub fn try_read(&self, buf: &mut [u8]) -> Result<usize>
pub fn try_read(&self, buf: &mut [u8]) -> Result<usize>
Read what is there now. Ok(0) is clean end of stream;
Error::WouldBlock means nothing yet.
Sourcepub fn try_read_exact(&self, buf: &mut [u8]) -> Result<()>
pub fn try_read_exact(&self, buf: &mut [u8]) -> Result<()>
Read the complete buffer atomically. When it is not all available,
returns Error::WouldBlock without consuming a prefix.
Sourcepub fn blocking_read(&self, buf: &mut [u8]) -> Result<usize>
pub fn blocking_read(&self, buf: &mut [u8]) -> Result<usize>
Park until something can be read, then read it. Ok(0) is clean
end of stream. Blocks the thread; an async runtime uses AsyncRead.
Sourcepub fn stop_reading(&self)
pub fn stop_reading(&self)
Tell the peer’s writer that nothing more will be read, without letting go of the stream.
What dropping this half says, for a holder that keeps its halves between exchanges. Without it a writer the reader has given up on — a client gone mid-response — waits on a full ring that nobody will empty. Re-arming the stream clears it again.
Sourcepub fn blocking_read_chunk(&self, max: usize) -> Result<Bytes>
pub fn blocking_read_chunk(&self, max: usize) -> Result<Bytes>
Up to max bytes as one owned chunk; empty at clean end of stream.
Sourcepub fn wait_readable_timeout(&self, timeout: Duration) -> Result<bool>
pub fn wait_readable_timeout(&self, timeout: Duration) -> Result<bool>
The same wait, bounded: false is the timeout and nothing else.
Sourcepub fn wait_readable(&self) -> Result<()>
pub fn wait_readable(&self) -> Result<()>
Park until a read would make progress or the direction ended.