diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2023-02-21 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2023-03-06 12:24:15 +0100 |
| commit | defa2456246a8272ceace9c1cdccdf2e4c36175e (patch) | |
| tree | 707a262f47a0659bdfe1d6698ac8ec99019c89b4 /library/std/src/sys/unix/fd.rs | |
| parent | 0fbfc3e76916521b509b63286296dd0762170d34 (diff) | |
| download | rust-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.rs | 9 |
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 { |
