use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut};
use crate::os::yggdrasil::io::{AsRawFd, FromRawFd, OwnedFd, RawFd};
use crate::sys::cvt_io;
use crate::sys::io::FileDesc;

pub struct AnonPipe(FileDesc);

impl AnonPipe {
    pub fn read(&self, _buf: &mut [u8]) -> io::Result<usize> {
        todo!()
    }

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

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

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

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

    pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
        unsafe { cvt_io(yggdrasil_rt::sys::write(self.as_raw_fd(), buf)) }
    }

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

    pub fn is_write_vectored(&self) -> bool {
        todo!()
    }
}

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

impl From<OwnedFd> for AnonPipe {
    fn from(_fd: OwnedFd) -> Self {
        todo!()
    }
}

pub fn read2(_p1: AnonPipe, _v1: &mut Vec<u8>, _p2: AnonPipe, _v2: &mut Vec<u8>) -> io::Result<()> {
    todo!()
}
