pub struct Handle { /* private fields */ }Expand description
An open, classified handle to a filesystem entry obtained via O_PATH|O_NOFOLLOW.
The fd is opened with O_PATH, so it cannot be used for reading; it exists
solely to identify the entry (for further openat calls relative to it) and
to carry the stat snapshot. A symlink entry is never followed: it yields a
Handle with kind() == EntryKind::Symlink.
Implementations§
Source§impl Handle
impl Handle
Sourcepub fn meta(&self) -> &FileMeta
pub fn meta(&self) -> &FileMeta
A snapshot of the entry’s metadata at the time the handle was opened.
Sourcepub fn as_fd(&self) -> BorrowedFd<'_>
pub fn as_fd(&self) -> BorrowedFd<'_>
Borrow the underlying file descriptor.
Sourcepub fn try_clone(&self) -> Result<Handle>
pub fn try_clone(&self) -> Result<Handle>
Duplicate this handle, sharing the same pinned inode via a dup’d
(F_DUPFD_CLOEXEC) O_PATH file descriptor and copying the cached
classification + stat snapshot.
This is a pure fd dup — it opens nothing, follows nothing, and stats
nothing on the filesystem, so it preserves every TOCTOU property of the
original O_PATH|O_NOFOLLOW handle (the clone pins the exact same inode and
cannot be redirected by a concurrent rename/symlink swap). It lets a walk
that classifies an entry once hand an owned handle to a deferred (post-order)
step without a second openat/fstatat on the entry.
Sourcepub async fn read_symlink(&self, side: Side) -> Result<(PathBuf, FileMeta)>
pub async fn read_symlink(&self, side: Side) -> Result<(PathBuf, FileMeta)>
Read this symlink’s target and metadata from the one pinned O_PATH fd: the target via the
empty-path readlinkat (read_link_handle) and the metadata from this handle’s fstat
snapshot. Both describe the same pinned inode, so they are a faithful pair (the symlink
analogue of Dir::open_file_read’s (File, FileMeta)). Errors if the handle is not a
symlink (the empty-path read requires a symlink fd).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Handle
impl RefUnwindSafe for Handle
impl Send for Handle
impl Sync for Handle
impl Unpin for Handle
impl UnsafeUnpin for Handle
impl UnwindSafe for Handle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request