/// `read(fd, buf)`—Reads from a stream. /// /// This is equivalent to [`read`], except that it can read into uninitialized /// memory. It returns the slice that was initialized by this function and the /// slice that remains uninitialized. #[inline] pubfn read_uninit<Fd: AsFd>(
fd: Fd,
buf: &mut [MaybeUninit<u8>],
) -> io::Result<(&mut [u8], &mut [MaybeUninit<u8>])> { // Get number of initialized bytes. let length = unsafe { backend::io::syscalls::read(fd.as_fd(), buf.as_mut_ptr() as *mut u8, buf.len()) };
// Split into the initialized and uninitialized portions.
Ok(unsafe { split_init(buf, length?) })
}
/// `pread(fd, buf, offset)`—Reads from a file at a given position. /// /// This is equivalent to [`pread`], except that it can read into uninitialized /// memory. It returns the slice that was initialized by this function and the /// slice that remains uninitialized. #[inline] pubfn pread_uninit<Fd: AsFd>(
fd: Fd,
buf: &mut [MaybeUninit<u8>],
offset: u64,
) -> io::Result<(&mut [u8], &mut [MaybeUninit<u8>])> { let length = unsafe {
backend::io::syscalls::pread(fd.as_fd(), buf.as_mut_ptr() as *mut u8, buf.len(), offset)
};
Ok(unsafe { split_init(buf, length?) })
}
/// `pwritev(fd, bufs, offset)`—Writes to a file at a given position from /// multiple buffers. /// /// Contrary to POSIX, on many popular platforms including Linux and FreeBSD, /// if the file is opened in append mode, this ignores the offset appends the /// data to the end of the file. /// /// # References /// - [Linux] /// - [FreeBSD] /// - [NetBSD] /// - [OpenBSD] /// - [DragonFly BSD] /// - [illumos] /// /// [Linux]: https://man7.org/linux/man-pages/man2/pwritev.2.html /// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=pwritev&sektion=2 /// [NetBSD]: https://man.netbsd.org/pwritev.2 /// [OpenBSD]: https://man.openbsd.org/pwritev.2 /// [DragonFly BSD]: https://man.dragonflybsd.org/?command=pwritev§ion=2 /// [illumos]: https://illumos.org/man/2/pwritev #[cfg(not(any(
target_os = "espidf",
target_os = "haiku",
target_os = "horizon",
target_os = "nto",
target_os = "redox",
target_os = "solaris",
target_os = "vita"
)))] #[inline] pubfn pwritev<Fd: AsFd>(fd: Fd, bufs: &[IoSlice<'_>], offset: u64) -> io::Result<usize> {
backend::io::syscalls::pwritev(fd.as_fd(), bufs, offset)
}
/// `preadv2(fd, bufs, offset, flags)`—Reads data, with several options. /// /// An `offset` of `u64::MAX` means to use and update the current file offset. /// /// # References /// - [Linux] /// /// [Linux]: https://man7.org/linux/man-pages/man2/preadv2.2.html #[cfg(linux_kernel)] #[inline] pubfn preadv2<Fd: AsFd>(
fd: Fd,
bufs: &mut [IoSliceMut<'_>],
offset: u64,
flags: ReadWriteFlags,
) -> io::Result<usize> {
backend::io::syscalls::preadv2(fd.as_fd(), bufs, offset, flags)
}
/// `pwritev2(fd, bufs, offset, flags)`—Writes data, with several options. /// /// An `offset` of `u64::MAX` means to use and update the current file offset. /// /// # References /// - [Linux] /// /// [Linux]: https://man7.org/linux/man-pages/man2/pwritev2.2.html #[cfg(linux_kernel)] #[inline] pubfn pwritev2<Fd: AsFd>(
fd: Fd,
bufs: &[IoSlice<'_>],
offset: u64,
flags: ReadWriteFlags,
) -> io::Result<usize> {
backend::io::syscalls::pwritev2(fd.as_fd(), bufs, offset, flags)
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet am 2026-06-20)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.