Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions tokio/src/net/unix/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,14 @@ impl Sender {
/// number of bytes written. If the pipe is not ready to write data,
/// `Err(io::ErrorKind::WouldBlock)` is returned.
///
/// # Notes
///
/// To avoid unnecessary syscalls, this will only attempt the write
/// operation if the OS has informed Tokio that this pipe has become
/// writable. Because of this, `try_write()` may fail with a
/// [`WouldBlock`] error if Tokio has not yet heard from the OS that
/// this pipe has become writable.
///
/// # Examples
///
/// ```no_run
Expand Down Expand Up @@ -650,6 +658,8 @@ impl Sender {
/// Ok(())
/// }
/// ```
///
/// [`WouldBlock`]: std::io::ErrorKind::WouldBlock
pub fn try_write(&self, buf: &[u8]) -> io::Result<usize> {
self.io
.registration()
Expand Down Expand Up @@ -681,6 +691,14 @@ impl Sender {
/// number of bytes written. If the pipe is not ready to write data,
/// `Err(io::ErrorKind::WouldBlock)` is returned.
///
/// # Notes
///
/// To avoid unnecessary syscalls, this will only attempt the write
/// operation if the OS has informed Tokio that this pipe has become
/// writable. Because of this, `try_write_vectored()` may fail with a
/// [`WouldBlock`] error if Tokio has not yet heard from the OS that
/// this pipe has become writable.
///
/// # Examples
///
/// ```no_run
Expand Down Expand Up @@ -716,6 +734,8 @@ impl Sender {
/// Ok(())
/// }
/// ```
///
/// [`WouldBlock`]: std::io::ErrorKind::WouldBlock
pub fn try_write_vectored(&self, buf: &[io::IoSlice<'_>]) -> io::Result<usize> {
self.io
.registration()
Expand Down Expand Up @@ -1152,6 +1172,14 @@ impl Receiver {
/// If the pipe is not ready to read data,
/// `Err(io::ErrorKind::WouldBlock)` is returned.
///
/// # Notes
///
/// To avoid unnecessary syscalls, this will only attempt the read
/// operation if the OS has informed Tokio that this pipe has become
/// readable. Because of this, `try_read()` may fail with a
/// [`WouldBlock`] error if Tokio has not yet heard from the OS that
/// this pipe has become readable.
///
/// # Examples
///
/// ```no_run
Expand Down Expand Up @@ -1189,6 +1217,8 @@ impl Receiver {
/// Ok(())
/// }
/// ```
///
/// [`WouldBlock`]: std::io::ErrorKind::WouldBlock
pub fn try_read(&self, buf: &mut [u8]) -> io::Result<usize> {
self.io
.registration()
Expand Down Expand Up @@ -1220,6 +1250,14 @@ impl Receiver {
/// closed and will no longer write data. If the pipe is not ready to read
/// data `Err(io::ErrorKind::WouldBlock)` is returned.
///
/// # Notes
///
/// To avoid unnecessary syscalls, this will only attempt the read
/// operation if the OS has informed Tokio that this pipe has become
/// readable. Because of this, `try_read_vectored()` may fail with a
/// [`WouldBlock`] error if Tokio has not yet heard from the OS that
/// this pipe has become readable.
///
/// # Examples
///
/// ```no_run
Expand Down Expand Up @@ -1263,6 +1301,8 @@ impl Receiver {
/// Ok(())
/// }
/// ```
///
/// [`WouldBlock`]: std::io::ErrorKind::WouldBlock
pub fn try_read_vectored(&self, bufs: &mut [io::IoSliceMut<'_>]) -> io::Result<usize> {
self.io
.registration()
Expand Down Expand Up @@ -1322,6 +1362,14 @@ impl Receiver {
/// closed and will no longer write data. If the pipe is not ready to read
/// data `Err(io::ErrorKind::WouldBlock)` is returned.
///
/// # Notes
///
/// To avoid unnecessary syscalls, this will only attempt the read
/// operation if the OS has informed Tokio that this pipe has become
/// readable. Because of this, `try_read_buf()` may fail with a
/// [`WouldBlock`] error if Tokio has not yet heard from the OS that
/// this pipe has become readable.
///
/// # Examples
///
/// ```no_run
Expand Down Expand Up @@ -1358,6 +1406,8 @@ impl Receiver {
/// Ok(())
/// }
/// ```
///
/// [`WouldBlock`]: std::io::ErrorKind::WouldBlock
pub fn try_read_buf<B: BufMut>(&self, buf: &mut B) -> io::Result<usize> {
self.io.registration().try_io(Interest::READABLE, || {
use std::io::Read;
Expand Down