unsupported.rs - source
Description: Source of the Rust file `library/std/src/sys/pipe/unsupported.rs`.

#
std/sys/pipe/
unsupported.rs

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