Skip to content

Commit 02bf0de

Browse files
committed
Enable std::io::copy specialisation for std::pipe::{PipeReader, PipeWriter}
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
1 parent 1f83bf3 commit 02bf0de

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

std/src/sys/pal/unix/kernel_copy.rs

+25
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ use crate::net::TcpStream;
5454
use crate::os::unix::fs::FileTypeExt;
5555
use crate::os::unix::io::{AsRawFd, FromRawFd, RawFd};
5656
use crate::os::unix::net::UnixStream;
57+
use crate::pipe::{PipeReader, PipeWriter};
5758
use crate::process::{ChildStderr, ChildStdin, ChildStdout};
5859
use crate::ptr;
5960
use crate::sync::atomic::{AtomicBool, AtomicU8, Ordering};
@@ -404,6 +405,30 @@ impl CopyWrite for &UnixStream {
404405
}
405406
}
406407

408+
impl CopyRead for PipeReader {
409+
fn properties(&self) -> CopyParams {
410+
CopyParams(FdMeta::Pipe, Some(self.as_raw_fd()))
411+
}
412+
}
413+
414+
impl CopyRead for &PipeReader {
415+
fn properties(&self) -> CopyParams {
416+
CopyParams(FdMeta::Pipe, Some(self.as_raw_fd()))
417+
}
418+
}
419+
420+
impl CopyWrite for PipeWriter {
421+
fn properties(&self) -> CopyParams {
422+
CopyParams(FdMeta::Pipe, Some(self.as_raw_fd()))
423+
}
424+
}
425+
426+
impl CopyWrite for &PipeWriter {
427+
fn properties(&self) -> CopyParams {
428+
CopyParams(FdMeta::Pipe, Some(self.as_raw_fd()))
429+
}
430+
}
431+
407432
impl CopyWrite for ChildStdin {
408433
fn properties(&self) -> CopyParams {
409434
CopyParams(FdMeta::Pipe, Some(self.as_raw_fd()))

0 commit comments

Comments
 (0)