summaryrefslogtreecommitdiffstats
path: root/tokio
diff options
context:
space:
mode:
authorJohn-John Tedro <udoprog@tedro.se>2020-10-16 10:48:13 +0200
committerJohn-John Tedro <udoprog@tedro.se>2020-10-16 11:55:35 +0200
commit1644511bdfe4711b98df3dbfe8b22cd1ec420f50 (patch)
tree2b685b4ed1dc6bda112f72defe5c1cb7ccf8d1cc /tokio
parentdc9742fbea6a17067e0c42f12d1a421e7f227e65 (diff)
Update documentation of AsyncRead to reflect use of ReadBuf
Diffstat (limited to 'tokio')
-rw-r--r--tokio/src/io/async_read.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/tokio/src/io/async_read.rs b/tokio/src/io/async_read.rs
index b9b0f437..1ca045bd 100644
--- a/tokio/src/io/async_read.rs
+++ b/tokio/src/io/async_read.rs
@@ -15,9 +15,9 @@ use std::task::{Context, Poll};
/// Specifically, this means that the `poll_read` function will return one of
/// the following:
///
-/// * `Poll::Ready(Ok(n))` means that `n` bytes of data was immediately read
-/// and placed into the output buffer, where `n` == 0 implies that EOF has
-/// been reached.
+/// * `Poll::Ready(Ok(()))` means that data was immediately read and placed into
+/// the output buffer. If no data was read (`buf.filled().is_empty()`) it
+/// implies that EOF has been reached.
///
/// * `Poll::Pending` means that no data was read into the buffer
/// provided. The I/O object is not currently readable but may become readable
@@ -42,12 +42,13 @@ use std::task::{Context, Poll};
pub trait AsyncRead {
/// Attempts to read from the `AsyncRead` into `buf`.
///
- /// On success, returns `Poll::Ready(Ok(num_bytes_read))`.
+ /// On success, returns `Poll::Ready(Ok(()))` and fills `buf` with data
+ /// read. If no data was read (`buf.filled().is_empty()`) it implies that
+ /// EOF has been reached.
///
- /// If no data is available for reading, the method returns
- /// `Poll::Pending` and arranges for the current task (via
- /// `cx.waker()`) to receive a notification when the object becomes
- /// readable or is closed.
+ /// If no data is available for reading, the method returns `Poll::Pending`
+ /// and arranges for the current task (via `cx.waker()`) to receive a
+ /// notification when the object becomes readable or is closed.
fn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,