Skip to content

Commit

Permalink
Rollup merge of #128303 - NobodyXu:specialise-for-pipe, r=cuviper
Browse files Browse the repository at this point in the history
Enable `std::io::copy` specialisation for `std::pipe::{PipeReader, PipeWriter}`

Enable `std::io::copy` specialisation on unix for the newly added anonymous pipe API, tracking issue #127154
  • Loading branch information
matthiaskrgr authored Aug 3, 2024
2 parents 47a795b + 649b431 commit 95d9f1c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions library/std/src/sys/pal/unix/kernel_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ use crate::net::TcpStream;
use crate::os::unix::fs::FileTypeExt;
use crate::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use crate::os::unix::net::UnixStream;
use crate::pipe::{PipeReader, PipeWriter};
use crate::process::{ChildStderr, ChildStdin, ChildStdout};
use crate::ptr;
use crate::sync::atomic::{AtomicBool, AtomicU8, Ordering};
Expand Down Expand Up @@ -405,6 +406,30 @@ impl CopyWrite for &UnixStream {
}
}

impl CopyRead for PipeReader {
fn properties(&self) -> CopyParams {
CopyParams(FdMeta::Pipe, Some(self.as_raw_fd()))
}
}

impl CopyRead for &PipeReader {
fn properties(&self) -> CopyParams {
CopyParams(FdMeta::Pipe, Some(self.as_raw_fd()))
}
}

impl CopyWrite for PipeWriter {
fn properties(&self) -> CopyParams {
CopyParams(FdMeta::Pipe, Some(self.as_raw_fd()))
}
}

impl CopyWrite for &PipeWriter {
fn properties(&self) -> CopyParams {
CopyParams(FdMeta::Pipe, Some(self.as_raw_fd()))
}
}

impl CopyWrite for ChildStdin {
fn properties(&self) -> CopyParams {
CopyParams(FdMeta::Pipe, Some(self.as_raw_fd()))
Expand Down

0 comments on commit 95d9f1c

Please sign in to comment.