Skip to content

Commit

Permalink
Rollup merge of rust-lang#128303 - NobodyXu:specialise-for-pipe, r=cu…
Browse files Browse the repository at this point in the history
…viper

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 rust-lang#127154
  • Loading branch information
matthiaskrgr authored Aug 3, 2024
2 parents 1967a12 + 02bf0de commit 0ee09fe
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions 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 0ee09fe

Please sign in to comment.