@@ -5,9 +5,11 @@ use std::task::{Context, Poll};
55
66/// Writes bytes asynchronously.
77///
8- /// The trait inherits from [`std::io::Write`] and indicates that an I/O object is
9- /// **nonblocking**. All non-blocking I/O objects must return an error when
10- /// bytes cannot be written instead of blocking the current thread.
8+ /// This trait is analogous to the [`std::io::Write`] trait, but integrates with
9+ /// the asynchronous task system. In particular, the [`poll_write`] method,
10+ /// unlike [`Write::write`], will automatically queue the current task for wakeup
11+ /// and return if data is not yet available, rather than blocking the calling
12+ /// thread.
1113///
1214/// Specifically, this means that the [`poll_write`] function will return one of
1315/// the following:
@@ -25,22 +27,15 @@ use std::task::{Context, Poll};
2527/// * `Poll::Ready(Err(e))` for other errors are standard I/O errors coming from the
2628/// underlying object.
2729///
28- /// This trait importantly means that the [`write`][stdwrite] method only works in
29- /// the context of a future's task. The object may panic if used outside of a task.
30- ///
31- /// Note that this trait also represents that the [`Write::flush`][stdflush] method
32- /// works very similarly to the `write` method, notably that `Ok(())` means that the
33- /// writer has successfully been flushed, a "would block" error means that the
34- /// current task is ready to receive a notification when flushing can make more
35- /// progress, and otherwise normal errors can happen as well.
30+ /// This trait importantly means that the `write` method only works in the
31+ /// context of a future's task. The object may panic if used outside of a task.
3632///
3733/// Utilities for working with `AsyncWrite` values are provided by
3834/// [`AsyncWriteExt`].
3935///
4036/// [`std::io::Write`]: std::io::Write
37+ /// [`Write::write`]: std::io::Write::write()
4138/// [`poll_write`]: AsyncWrite::poll_write()
42- /// [stdwrite]: std::io::Write::write()
43- /// [stdflush]: std::io::Write::flush()
4439/// [`AsyncWriteExt`]: crate::io::AsyncWriteExt
4540pub trait AsyncWrite {
4641 /// Attempt to write bytes from `buf` into the object.
0 commit comments