about summary refs log tree commit diff
path: root/library/std/src/sys/unix/fd.rs
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2023-02-21 00:00:00 +0000
committerTomasz Miąsko <tomasz.miasko@gmail.com>2023-03-06 12:24:15 +0100
commitdefa2456246a8272ceace9c1cdccdf2e4c36175e (patch)
tree707a262f47a0659bdfe1d6698ac8ec99019c89b4 /library/std/src/sys/unix/fd.rs
parent0fbfc3e76916521b509b63286296dd0762170d34 (diff)
downloadrust-defa2456246a8272ceace9c1cdccdf2e4c36175e.tar.gz
rust-defa2456246a8272ceace9c1cdccdf2e4c36175e.zip
Implement read_buf for a few more types
Implement read_buf for TcpStream, Stdin, StdinLock, ChildStdout,
ChildStderr (and internally for AnonPipe, Handle, Socket), so
that it skips buffer initialization.

The other provided methods like read_to_string and read_to_end are
implemented in terms of read_buf and so benefit from the optimization
as well.

This commit also implements read_vectored and is_read_vectored where
applicable.
Diffstat (limited to 'library/std/src/sys/unix/fd.rs')
-rw-r--r--library/std/src/sys/unix/fd.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/library/std/src/sys/unix/fd.rs b/library/std/src/sys/unix/fd.rs
index 9874af4d3e2..ce5c048f252 100644
--- a/library/std/src/sys/unix/fd.rs
+++ b/library/std/src/sys/unix/fd.rs
@@ -469,6 +469,15 @@ impl<'a> Read for &'a FileDesc {
     fn read_buf(&mut self, cursor: BorrowedCursor<'_>) -> io::Result<()> {
         (**self).read_buf(cursor)
     }
+
+    fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
+        (**self).read_vectored(bufs)
+    }
+
+    #[inline]
+    fn is_read_vectored(&self) -> bool {
+        (**self).is_read_vectored()
+    }
 }
 
 impl AsInner<OwnedFd> for FileDesc {