diff --git a/tokio/src/net/tcp/split.rs b/tokio/src/net/tcp/split.rs index 343d4fde7..1a1e22253 100644 --- a/tokio/src/net/tcp/split.rs +++ b/tokio/src/net/tcp/split.rs @@ -141,9 +141,9 @@ impl ReadHalf<'_> { /// Waits for any of the requested ready states. /// - /// This function is usually paired with `try_read()` or `try_write()`. It - /// can be used to concurrently read / write to the same socket on a single - /// task without splitting the socket. + /// This function is usually paired with [`try_read()`]. It can be used instead + /// of [`readable()`] to check the returned ready set for [`Ready::READABLE`] + /// and [`Ready::READ_CLOSED`] events. /// /// The function may complete without the socket being ready. This is a /// false-positive and attempting an operation will return with @@ -153,6 +153,9 @@ impl ReadHalf<'_> { /// /// This function is equivalent to [`TcpStream::ready`]. /// + /// [`try_read()`]: Self::try_read + /// [`readable()`]: Self::readable + /// /// # Cancel safety /// /// This method is cancel safe. Once a readiness event occurs, the method @@ -275,9 +278,9 @@ impl ReadHalf<'_> { impl WriteHalf<'_> { /// Waits for any of the requested ready states. /// - /// This function is usually paired with `try_read()` or `try_write()`. It - /// can be used to concurrently read / write to the same socket on a single - /// task without splitting the socket. + /// This function is usually paired with [`try_write()`]. It can be used instead + /// of [`writable()`] to check the returned ready set for [`Ready::WRITABLE`] + /// and [`Ready::WRITE_CLOSED`] events. /// /// The function may complete without the socket being ready. This is a /// false-positive and attempting an operation will return with @@ -287,6 +290,9 @@ impl WriteHalf<'_> { /// /// This function is equivalent to [`TcpStream::ready`]. /// + /// [`try_write()`]: Self::try_write + /// [`writable()`]: Self::writable + /// /// # Cancel safety /// /// This method is cancel safe. Once a readiness event occurs, the method diff --git a/tokio/src/net/tcp/split_owned.rs b/tokio/src/net/tcp/split_owned.rs index 53fc5f06f..6771d6497 100644 --- a/tokio/src/net/tcp/split_owned.rs +++ b/tokio/src/net/tcp/split_owned.rs @@ -196,9 +196,9 @@ impl OwnedReadHalf { /// Waits for any of the requested ready states. /// - /// This function is usually paired with `try_read()` or `try_write()`. It - /// can be used to concurrently read / write to the same socket on a single - /// task without splitting the socket. + /// This function is usually paired with [`try_read()`]. It can be used instead + /// of [`readable()`] to check the returned ready set for [`Ready::READABLE`] + /// and [`Ready::READ_CLOSED`] events. /// /// The function may complete without the socket being ready. This is a /// false-positive and attempting an operation will return with @@ -208,6 +208,9 @@ impl OwnedReadHalf { /// /// This function is equivalent to [`TcpStream::ready`]. /// + /// [`try_read()`]: Self::try_read + /// [`readable()`]: Self::readable + /// /// # Cancel safety /// /// This method is cancel safe. Once a readiness event occurs, the method @@ -357,9 +360,9 @@ impl OwnedWriteHalf { /// Waits for any of the requested ready states. /// - /// This function is usually paired with `try_read()` or `try_write()`. It - /// can be used to concurrently read / write to the same socket on a single - /// task without splitting the socket. + /// This function is usually paired with [`try_write()`]. It can be used instead + /// of [`writable()`] to check the returned ready set for [`Ready::WRITABLE`] + /// and [`Ready::WRITE_CLOSED`] events. /// /// The function may complete without the socket being ready. This is a /// false-positive and attempting an operation will return with @@ -369,6 +372,9 @@ impl OwnedWriteHalf { /// /// This function is equivalent to [`TcpStream::ready`]. /// + /// [`try_write()`]: Self::try_write + /// [`writable()`]: Self::writable + /// /// # Cancel safety /// /// This method is cancel safe. Once a readiness event occurs, the method diff --git a/tokio/src/net/unix/split.rs b/tokio/src/net/unix/split.rs index 816a2578b..6fc7067a7 100644 --- a/tokio/src/net/unix/split.rs +++ b/tokio/src/net/unix/split.rs @@ -55,9 +55,20 @@ pub(crate) fn split(stream: &mut UnixStream) -> (ReadHalf<'_>, WriteHalf<'_>) { impl ReadHalf<'_> { /// Wait for any of the requested ready states. /// - /// This function is usually paired with `try_read()` or `try_write()`. It - /// can be used to concurrently read / write to the same socket on a single - /// task without splitting the socket. + /// This function is usually paired with [`try_read()`]. It can be used instead + /// of [`readable()`] to check the returned ready set for [`Ready::READABLE`] + /// and [`Ready::READ_CLOSED`] events. + /// + /// The function may complete without the socket being ready. This is a + /// false-positive and attempting an operation will return with + /// `io::ErrorKind::WouldBlock`. The function can also return with an empty + /// [`Ready`] set, so you should always check the returned value and possibly + /// wait again if the requested states are not set. + /// + /// This function is equivalent to [`UnixStream::ready`]. + /// + /// [`try_read()`]: Self::try_read + /// [`readable()`]: Self::readable /// /// # Cancel safety /// @@ -178,9 +189,9 @@ impl ReadHalf<'_> { impl WriteHalf<'_> { /// Waits for any of the requested ready states. /// - /// This function is usually paired with `try_read()` or `try_write()`. It - /// can be used to concurrently read / write to the same socket on a single - /// task without splitting the socket. + /// This function is usually paired with [`try_write()`]. It can be used instead + /// of [`writable()`] to check the returned ready set for [`Ready::WRITABLE`] + /// and [`Ready::WRITE_CLOSED`] events. /// /// The function may complete without the socket being ready. This is a /// false-positive and attempting an operation will return with @@ -188,6 +199,11 @@ impl WriteHalf<'_> { /// [`Ready`] set, so you should always check the returned value and possibly /// wait again if the requested states are not set. /// + /// This function is equivalent to [`UnixStream::ready`]. + /// + /// [`try_write()`]: Self::try_write + /// [`writable()`]: Self::writable + /// /// # Cancel safety /// /// This method is cancel safe. Once a readiness event occurs, the method diff --git a/tokio/src/net/unix/split_owned.rs b/tokio/src/net/unix/split_owned.rs index 2cb561d4b..d1c6f93de 100644 --- a/tokio/src/net/unix/split_owned.rs +++ b/tokio/src/net/unix/split_owned.rs @@ -110,9 +110,9 @@ impl OwnedReadHalf { /// Waits for any of the requested ready states. /// - /// This function is usually paired with `try_read()` or `try_write()`. It - /// can be used to concurrently read / write to the same socket on a single - /// task without splitting the socket. + /// This function is usually paired with [`try_read()`]. It can be used instead + /// of [`readable()`] to check the returned ready set for [`Ready::READABLE`] + /// and [`Ready::READ_CLOSED`] events. /// /// The function may complete without the socket being ready. This is a /// false-positive and attempting an operation will return with @@ -120,6 +120,11 @@ impl OwnedReadHalf { /// [`Ready`] set, so you should always check the returned value and possibly /// wait again if the requested states are not set. /// + /// This function is equivalent to [`UnixStream::ready`]. + /// + /// [`try_read()`]: Self::try_read + /// [`readable()`]: Self::readable + /// /// # Cancel safety /// /// This method is cancel safe. Once a readiness event occurs, the method @@ -267,9 +272,9 @@ impl OwnedWriteHalf { /// Waits for any of the requested ready states. /// - /// This function is usually paired with `try_read()` or `try_write()`. It - /// can be used to concurrently read / write to the same socket on a single - /// task without splitting the socket. + /// This function is usually paired with [`try_write()`]. It can be used instead + /// of [`writable()`] to check the returned ready set for [`Ready::WRITABLE`] + /// and [`Ready::WRITE_CLOSED`] events. /// /// The function may complete without the socket being ready. This is a /// false-positive and attempting an operation will return with @@ -277,6 +282,11 @@ impl OwnedWriteHalf { /// [`Ready`] set, so you should always check the returned value and possibly /// wait again if the requested states are not set. /// + /// This function is equivalent to [`UnixStream::ready`]. + /// + /// [`try_write()`]: Self::try_write + /// [`writable()`]: Self::writable + /// /// # Cancel safety /// /// This method is cancel safe. Once a readiness event occurs, the method