about summary refs log tree commit diff
path: root/library/std/src/sys/pal/unsupported/pipe.rs
blob: 988e551de5223cde9481371b2367460faeb4b392 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
use crate::fmt;
use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut};
use crate::sys_common::{FromInner, IntoInner};

pub struct AnonPipe(!);

impl fmt::Debug for AnonPipe {
    fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
        self.0
    }
}

impl AnonPipe {
    pub fn try_clone(&self) -> io::Result<Self> {
        self.0
    }

    pub fn read(&self, _buf: &mut [u8]) -> io::Result<usize> {
        self.0
    }

    pub fn read_buf(&self, _buf: BorrowedCursor<'_>) -> io::Result<()> {
        self.0
    }

    pub fn read_vectored(&self, _bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
        self.0
    }

    pub fn is_read_vectored(&self) -> bool {
        self.0
    }

    pub fn read_to_end(&self, _buf: &mut Vec<u8>) -> io::Result<usize> {
        self.0
    }

    pub fn write(&self, _buf: &[u8]) -> io::Result<usize> {
        self.0
    }

    pub fn write_vectored(&self, _bufs: &[IoSlice<'_>]) -> io::Result<usize> {
        self.0
    }

    pub fn is_write_vectored(&self) -> bool {
        self.0
    }

    pub fn diverge(&self) -> ! {
        self.0
    }
}

pub fn read2(p1: AnonPipe, _v1: &mut Vec<u8>, _p2: AnonPipe, _v2: &mut Vec<u8>) -> io::Result<()> {
    match p1.0 {}
}

impl FromInner<!> for AnonPipe {
    fn from_inner(inner: !) -> Self {
        inner
    }
}

impl IntoInner<!> for AnonPipe {
    fn into_inner(self) -> ! {
        self.0
    }
}

#[cfg(any(unix, target_os = "hermit", target_os = "wasi"))]
mod unix_traits {
    use super::AnonPipe;
    use crate::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
    use crate::sys_common::FromInner;

    impl AsRawFd for AnonPipe {
        #[inline]
        fn as_raw_fd(&self) -> RawFd {
            self.0
        }
    }

    impl AsFd for AnonPipe {
        fn as_fd(&self) -> BorrowedFd<'_> {
            self.0
        }
    }

    impl IntoRawFd for AnonPipe {
        fn into_raw_fd(self) -> RawFd {
            self.0
        }
    }

    impl FromRawFd for AnonPipe {
        unsafe fn from_raw_fd(_: RawFd) -> Self {
            panic!("creating pipe on this platform is unsupported!")
        }
    }

    impl FromInner<OwnedFd> for AnonPipe {
        fn from_inner(_: OwnedFd) -> Self {
            panic!("creating pipe on this platform is unsupported!")
        }
    }
}