From c9d70c03bf47755ff3dad1d0560dfe7a1a64bbb4 Mon Sep 17 00:00:00 2001 From: Edward Shen Date: Thu, 27 May 2021 16:27:59 -0400 Subject: [PATCH] Clarify limits on return values on AsyncWrite --- tokio/src/io/async_write.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tokio/src/io/async_write.rs b/tokio/src/io/async_write.rs index 569fb9c949e..7ec1a302efa 100644 --- a/tokio/src/io/async_write.rs +++ b/tokio/src/io/async_write.rs @@ -45,7 +45,11 @@ use std::task::{Context, Poll}; pub trait AsyncWrite { /// Attempt to write bytes from `buf` into the object. /// - /// On success, returns `Poll::Ready(Ok(num_bytes_written))`. + /// On success, returns `Poll::Ready(Ok(num_bytes_written))`. If successful, + /// then it must be guaranteed that `n <= buf.len()`. A return value of `0` + /// typically means that the underlying object is no longer able to accept + /// bytes and will likely not be able to in the future as well, or that the + /// buffer provided is empty. /// /// If the object is not ready for writing, the method returns /// `Poll::Pending` and arranges for the current task (via