pub struct WriteHalf { /* private fields */ }Expand description
The writing end of one side. Dropping it without WriteHalf::finish
resets the direction, as a dropped socket would.
Implementations§
Source§impl WriteHalf
impl WriteHalf
Sourcepub async fn peer_closed(&mut self) -> Result<()>
pub async fn peer_closed(&mut self) -> Result<()>
Wait until this direction is reset or its reader stops reading, releases its half, or is reported dead. A clean FIN is not cancellation.
Uses the writer’s existing readiness registration. Dropping this future disarms the extra departure wake; it does not close the direction.
Sourcepub fn poll_peer_dead(&self, cx: &mut Context<'_>) -> Poll<Result<()>>
pub fn poll_peer_dead(&self, cx: &mut Context<'_>) -> Poll<Result<()>>
Wait for the peer’s confirmed node death, even while no bytes are being produced. Ordinary FIN and endpoint release are not death.
Shares the writer’s readiness registration: poll this from the same task as writes, not from a second concurrent writer task.
pub fn id(&self) -> StreamId
Sourcepub fn try_write(&self, buf: &[u8]) -> Result<usize>
pub fn try_write(&self, buf: &[u8]) -> Result<usize>
Write what fits now; Error::WouldBlock when the ring is full.
Sourcepub fn try_write_exact(&self, buf: &[u8]) -> Result<()>
pub fn try_write_exact(&self, buf: &[u8]) -> Result<()>
Write the complete buffer atomically. When it does not all fit,
returns Error::WouldBlock without publishing a prefix.
Sourcepub fn blocking_write(&self, buf: &[u8]) -> Result<usize>
pub fn blocking_write(&self, buf: &[u8]) -> Result<usize>
Park until something fits, then write it. Blocks the thread.
Sourcepub fn blocking_write_all(&self, buf: &[u8]) -> Result<()>
pub fn blocking_write_all(&self, buf: &[u8]) -> Result<()>
Write everything, waiting as needed. A failure part-way has already committed a prefix; nothing is replayed.
Sourcepub fn finish(&mut self) -> Result<()>
pub fn finish(&mut self) -> Result<()>
No more bytes from this side (FIN); what is buffered still reaches
the reader, then it sees a clean end. The other direction is
unaffected. AsyncWriteExt::shutdown does the same.
Sourcepub fn finish_quietly(&mut self)
pub fn finish_quietly(&mut self)
FIN without a ring, for a direction its reader already knows carries
nothing: the peer was told by other means — a frame that says the body
travelled with it — and will not read here. The flag is set as
WriteHalf::finish sets it and blocking waiters are counted as
always, but no doorbell rings, so nobody is woken to find an end it was
never going to look for. A reader that does look still sees it.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Abandon the direction: the reader gets an error and buffered bytes are discarded.
Sourcepub fn wait_writable_timeout(&self, timeout: Duration) -> Result<bool>
pub fn wait_writable_timeout(&self, timeout: Duration) -> Result<bool>
The same wait, bounded: false is the timeout and nothing else,
which is how a caller with a deadline of its own gives up without
giving up its stream.
Sourcepub fn wait_writable(&self) -> Result<()>
pub fn wait_writable(&self) -> Result<()>
Park until a write would make progress or the direction ended.
Sourcepub fn wait_writable_exact(&self, needed: usize) -> Result<()>
pub fn wait_writable_exact(&self, needed: usize) -> Result<()>
Park until an atomic write of needed bytes can be attempted.