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>])
| 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`]. |