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

Method new

src/fs/raw_dir.rs:128–142  ·  view source on GitHub ↗

Create a new iterator from the given file descriptor and buffer. Note: the buffer size may be trimmed to accommodate alignment requirements. # Examples ## Simple but non-portable These examples are non-portable, because file systems may not have a maximum file name length. If you can make assumptions that bound this length, then these examples may suffice. Using the heap: ``` # use std::mem:

(fd: Fd, buf: &'buf mut [MaybeUninit<u8>])

Source from the content-addressed store, hash-verified

126 /// }
127 /// ```
128 pub fn new(fd: Fd, buf: &'buf mut [MaybeUninit<u8>]) -> Self {
129 Self {
130 fd,
131 buf: {
132 let offset = buf.as_ptr().align_offset(align_of::<linux_dirent64>());
133 if offset < buf.len() {
134 &mut buf[offset..]
135 } else {
136 &mut []
137 }
138 },
139 initialized: 0,
140 offset: 0,
141 }
142 }
143}
144
145/// A raw directory entry, similar to [`std::fs::DirEntry`].

Callers

nothing calls this directly

Calls 2

as_ptrMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected