use crate::io::{IoSlice, IoSliceMut};
use crate::{imp, io};
use imp::fd::AsFd;
#[cfg(any(linux_raw, all(libc, any(target_os = "android", target_os = "linux"))))]
pub use imp::io::ReadWriteFlags;
#[inline]
pub fn read<Fd: AsFd>(fd: Fd, buf: &mut [u8]) -> io::Result<usize> {
imp::io::syscalls::read(fd.as_fd(), buf)
}
#[inline]
pub fn write<Fd: AsFd>(fd: Fd, buf: &[u8]) -> io::Result<usize> {
imp::io::syscalls::write(fd.as_fd(), buf)
}
#[inline]
pub fn pread<Fd: AsFd>(fd: Fd, buf: &mut [u8], offset: u64) -> io::Result<usize> {
imp::io::syscalls::pread(fd.as_fd(), buf, offset)
}
#[inline]
pub fn pwrite<Fd: AsFd>(fd: Fd, buf: &[u8], offset: u64) -> io::Result<usize> {
imp::io::syscalls::pwrite(fd.as_fd(), buf, offset)
}
#[inline]
pub fn readv<Fd: AsFd>(fd: Fd, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
imp::io::syscalls::readv(fd.as_fd(), bufs)
}
#[inline]
pub fn writev<Fd: AsFd>(fd: Fd, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
imp::io::syscalls::writev(fd.as_fd(), bufs)
}
#[cfg(not(target_os = "redox"))]
#[inline]
pub fn preadv<Fd: AsFd>(fd: Fd, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result<usize> {
imp::io::syscalls::preadv(fd.as_fd(), bufs, offset)
}
#[cfg(not(target_os = "redox"))]
#[inline]
pub fn pwritev<Fd: AsFd>(fd: Fd, bufs: &[IoSlice<'_>], offset: u64) -> io::Result<usize> {
imp::io::syscalls::pwritev(fd.as_fd(), bufs, offset)
}
#[cfg(any(linux_raw, all(libc, any(target_os = "android", target_os = "linux"))))]
#[inline]
pub fn preadv2<Fd: AsFd>(
fd: Fd,
bufs: &mut [IoSliceMut<'_>],
offset: u64,
flags: ReadWriteFlags,
) -> io::Result<usize> {
imp::io::syscalls::preadv2(fd.as_fd(), bufs, offset, flags)
}
#[cfg(any(linux_raw, all(libc, any(target_os = "android", target_os = "linux"))))]
#[inline]
pub fn pwritev2<Fd: AsFd>(
fd: Fd,
bufs: &[IoSlice<'_>],
offset: u64,
flags: ReadWriteFlags,
) -> io::Result<usize> {
imp::io::syscalls::pwritev2(fd.as_fd(), bufs, offset, flags)
}