Skip to content

Commit

Permalink
io: fix documents (#1231)
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e authored and carllerche committed Jul 2, 2019
1 parent 70eca18 commit ceed295
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions tokio-io/src/async_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ pub trait AsyncRead {
///
/// This function isn't actually `unsafe` to call but `unsafe` to implement.
/// The implementer must ensure that either the whole `buf` has been zeroed
/// or `read_buf()` overwrites the buffer without reading it and returns
/// or `poll_read_buf()` overwrites the buffer without reading it and returns
/// correct value.
///
/// This function is called from [`read_buf`].
/// This function is called from [`poll_read_buf`].
///
/// [`io::Read`]: https://doc.rust-lang.org/std/io/trait.Read.html
/// [`read_buf`]: #method.read_buf
/// [`poll_read_buf`]: #method.poll_read_buf
unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [u8]) -> bool {
for i in 0..buf.len() {
buf[i] = 0;
Expand Down
22 changes: 11 additions & 11 deletions tokio-io/src/async_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ use std::task::{Context, Poll};
/// Specifically, this means that the `poll_write` function will return one of
/// the following:
///
/// * `Ok(Async::Ready(n))` means that `n` bytes of data was immediately
/// * `Poll::Ready(Ok(n))` means that `n` bytes of data was immediately
/// written.
///
/// * `Ok(Async::NotReady)` means that no data was written from the buffer
/// * `Poll::Pending` means that no data was written from the buffer
/// provided. The I/O object is not currently writable but may become writable
/// in the future. Most importantly, **the current future's task is scheduled
/// to get unparked when the object is writable**. This means that like
/// `Future::poll` you'll receive a notification when the I/O object is
/// writable again.
///
/// * `Err(e)` for other errors are standard I/O errors coming from the
/// * `Poll::Ready(Err(e))` for other errors are standard I/O errors coming from the
/// underlying object.
///
/// This trait importantly means that the `write` method only works in the
Expand All @@ -38,10 +38,10 @@ use std::task::{Context, Poll};
pub trait AsyncWrite {
/// Attempt to write bytes from `buf` into the object.
///
/// On success, returns `Ok(Async::Ready(num_bytes_written))`.
/// On success, returns `Poll::Ready(Ok(num_bytes_written))`.
///
/// If the object is not ready for writing, the method returns
/// `Ok(Async::NotReady)` and arranges for the current task (via
/// `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_write(
Expand All @@ -53,10 +53,10 @@ pub trait AsyncWrite {
/// Attempt to flush the object, ensuring that any buffered data reach
/// their destination.
///
/// On success, returns `Ok(Async::Ready(()))`.
/// On success, returns `Poll::Ready(Ok(()))`.
///
/// If flushing cannot immediately complete, this method returns
/// `Ok(Async::NotReady)` and arranges for the current task (via
/// `Poll::Pending` and arranges for the current task (via
/// `cx.waker()`) to receive a notification when the object can make
/// progress towards flushing.
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>>;
Expand Down Expand Up @@ -89,21 +89,21 @@ pub trait AsyncWrite {
///
/// # Return value
///
/// This function returns a `Poll<(), io::Error>` classified as such:
/// This function returns a `Poll<io::Result<()>>` classified as such:
///
/// * `Ok(Async::Ready(()))` - indicates that the connection was
/// * `Poll::Ready(Ok(()))` - indicates that the connection was
/// successfully shut down and is now safe to deallocate/drop/close
/// resources associated with it. This method means that the current task
/// will no longer receive any notifications due to this method and the
/// I/O object itself is likely no longer usable.
///
/// * `Ok(Async::NotReady)` - indicates that shutdown is initiated but could
/// * `Poll::Pending` - indicates that shutdown is initiated but could
/// not complete just yet. This may mean that more I/O needs to happen to
/// continue this shutdown operation. The current task is scheduled to
/// receive a notification when it's otherwise ready to continue the
/// shutdown operation. When woken up this method should be called again.
///
/// * `Err(e)` - indicates a fatal error has happened with shutdown,
/// * `Poll::Ready(Err(e))` - indicates a fatal error has happened with shutdown,
/// indicating that the shutdown operation did not complete successfully.
/// This typically means that the I/O object is no longer usable.
///
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ pub use tokio_fs::{stderr, stdin, stdout, Stderr, Stdin, Stdout};
pub use tokio_io::{AsyncRead, AsyncWrite};

// Re-export io::Error so that users don't have to deal
// with conflicts when `use`ing `futures::io` and `std::io`.
// with conflicts when `use`ing `tokio::io` and `std::io`.
pub use std::io::{Error, ErrorKind, Result};

0 comments on commit ceed295

Please sign in to comment.