MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / pread

Function pread

src/io/read_write.rs:97–106  ·  view source on GitHub ↗
(
    fd: Fd,
    mut buf: Buf,
    offset: u64,
)

Source from the content-addressed store, hash-verified

95#[cfg(not(windows))]
96#[inline]
97pub fn pread<Fd: AsFd, Buf: Buffer<u8>>(
98 fd: Fd,
99 mut buf: Buf,
100 offset: u64,
101) -> io::Result<Buf::Output> {
102 // SAFETY: `pread` behaves.
103 let len = unsafe { backend::io::syscalls::pread(fd.as_fd(), buf.parts_mut(), offset)? };
104 // SAFETY: `pread` behaves.
105 unsafe { Ok(buf.assume_init(len)) }
106}
107
108/// `pwrite(fd, bufs)`—Writes to a file at a given position.
109///

Callers 4

test_readwrite_pFunction · 0.50
test_readwrite_p_uninitFunction · 0.50
test_p_offsetsFunction · 0.50
invalid_offset_preadFunction · 0.50

Calls 3

parts_mutMethod · 0.80
assume_initMethod · 0.80
as_fdMethod · 0.45

Tested by 4

test_readwrite_pFunction · 0.40
test_readwrite_p_uninitFunction · 0.40
test_p_offsetsFunction · 0.40
invalid_offset_preadFunction · 0.40