std/sys/pal/unsupported/
pipe.rs

1use crate::fmt;
2use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut};
3use crate::sys_common::{FromInner, IntoInner};
4
5pub struct AnonPipe(!);
6
7impl fmt::Debug for AnonPipe {
8    fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
9        self.0
10    }
11}
12
13impl AnonPipe {
14    pub fn try_clone(&self) -> io::Result<Self> {
15        self.0
16    }
17
18    pub fn read(&self, _buf: &mut [u8]) -> io::Result<usize> {
19        self.0
20    }
21
22    pub fn read_buf(&self, _buf: BorrowedCursor<'_>) -> io::Result<()> {
23        self.0
24    }
25
26    pub fn read_vectored(&self, _bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
27        self.0
28    }
29
30    pub fn is_read_vectored(&self) -> bool {
31        self.0
32    }
33
34    pub fn read_to_end(&self, _buf: &mut Vec<u8>) -> io::Result<usize> {
35        self.0
36    }
37
38    pub fn write(&self, _buf: &[u8]) -> io::Result<usize> {
39        self.0
40    }
41
42    pub fn write_vectored(&self, _bufs: &[IoSlice<'_>]) -> io::Result<usize> {
43        self.0
44    }
45
46    pub fn is_write_vectored(&self) -> bool {
47        self.0
48    }
49
50    pub fn diverge(&self) -> ! {
51        self.0
52    }
53}
54
55pub fn read2(p1: AnonPipe, _v1: &mut Vec<u8>, _p2: AnonPipe, _v2: &mut Vec<u8>) -> io::Result<()> {
56    match p1.0 {}
57}
58
59impl FromInner<!> for AnonPipe {
60    fn from_inner(inner: !) -> Self {
61        inner
62    }
63}
64
65impl IntoInner<!> for AnonPipe {
66    fn into_inner(self) -> ! {
67        self.0
68    }
69}
70
71#[cfg(any(unix, target_os = "hermit", target_os = "wasi"))]
72mod unix_traits {
73    use super::AnonPipe;
74    use crate::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
75    use crate::sys_common::FromInner;
76
77    impl AsRawFd for AnonPipe {
78        #[inline]
79        fn as_raw_fd(&self) -> RawFd {
80            self.0
81        }
82    }
83
84    impl AsFd for AnonPipe {
85        fn as_fd(&self) -> BorrowedFd<'_> {
86            self.0
87        }
88    }
89
90    impl IntoRawFd for AnonPipe {
91        fn into_raw_fd(self) -> RawFd {
92            self.0
93        }
94    }
95
96    impl FromRawFd for AnonPipe {
97        unsafe fn from_raw_fd(_: RawFd) -> Self {
98            panic!("creating pipe on this platform is unsupported!")
99        }
100    }
101
102    impl FromInner<OwnedFd> for AnonPipe {
103        fn from_inner(_: OwnedFd) -> Self {
104            panic!("creating pipe on this platform is unsupported!")
105        }
106    }
107}