Function rustix::fs::readlinkat_raw

source ·
pub fn readlinkat_raw<P: Arg, Fd: AsFd>(
    dirfd: Fd,
    path: P,
    buf: &mut [MaybeUninit<u8>]
) -> Result<(&mut [u8], &mut [MaybeUninit<u8>])>
Expand description

readlinkat(fd, path)—Reads the contents of a symlink, without allocating.

This is the “raw” version which avoids allocating, but which is significantly trickier to use; most users should use plain readlinkat.

This version writes bytes into the buffer and returns two slices, one containing the written bytes, and one containing the remaining uninitialized space. If the number of written bytes is equal to the length of the buffer, it means the buffer wasn’t big enough to hold the full string, and callers should try again with a bigger buffer.

§References