Function write_or_flush
pub(super) async fn write_or_flush<W: AsyncWrite + Unpin>(
write: &mut W,
pending: &[u8],
needs_flush: bool,
) -> Result<Wrote>Expand description
Writes one chunk of pending to write, or flushes when pending is
empty.
ยงCancel safety
This is cancellation-safe. It performs a single poll_write (or a single
poll_flush) and returns; it never tracks progress across awaits, so
dropping the future before it resolves writes nothing the caller is not told
about. The caller advances its own cursor by calling consume(n) only on a
returned Wrote::Bytes. This is why the loop uses write rather than
write_all: write_all keeps the progress cursor inside the future, which
a cancellation would lose.