pub struct RetainedDirectoryIdentity { /* private fields */ }Expand description
Retained, policy-neutral handle and identity for one exact directory.
The final path component is opened without following a symbolic link or Windows reparse point.
On Windows the retained handle shares reads and writes but omits delete sharing, preventing the
named directory from being renamed, deleted, or replaced while this value or one of its cloned
handles remains alive. Unix descriptors do not prevent namespace rename or replacement, so
callers must use Self::verify_path immediately before and after sensitive pathname work.
Implementations§
Source§impl RetainedDirectoryIdentity
impl RetainedDirectoryIdentity
Sourcepub fn open(path: &Path) -> Result<Self, DirectoryIdentityError>
pub fn open(path: &Path) -> Result<Self, DirectoryIdentityError>
Open and retain the exact plain directory currently named by an absolute path.
The returned file is opened for directory reads and can be safely duplicated for capability consumers. Metadata synchronization acquires a separate handle bound to this exact retained directory, so read-only installation directories can still be retained and verified.
§Errors
Returns a typed error when the path is not absolute, the final component is a symbolic link, reparse point, or non-directory, the platform cannot derive a persistent identity, or the pathname changes during initial binding.
Sourcepub fn identity(&self) -> &DirectoryFilesystemIdentity
pub fn identity(&self) -> &DirectoryFilesystemIdentity
Return the canonical identity captured from the retained handle.
Sourcepub fn as_file(&self) -> &File ⓘ
pub fn as_file(&self) -> &File ⓘ
Borrow the exact retained directory file for capability-based consumers.
Sourcepub fn try_clone_file(&self) -> Result<File, DirectoryIdentityError>
pub fn try_clone_file(&self) -> Result<File, DirectoryIdentityError>
Duplicate the exact retained directory handle or descriptor.
On Windows the duplicate preserves the original no-delete-sharing lifetime. On Unix it retains the same directory object but still does not prevent namespace rename.
§Errors
Returns a typed operating-system error when the handle cannot be duplicated.
Sourcepub fn verify_path(&self, path: &Path) -> Result<(), DirectoryIdentityError>
pub fn verify_path(&self, path: &Path) -> Result<(), DirectoryIdentityError>
Require the current absolute pathname to identify the same retained directory object.
Windows no-delete sharing keeps a successfully rebound pathname stable while the retained handle lives. Unix verification is an instantaneous identity check only; another process can rename or replace the path immediately after this method returns.
§Errors
Returns a typed open/validation error, or DirectoryIdentityErrorKind::IdentityMismatch
when the path no longer names this retained object.