Skip to main content

RetainedDirectoryIdentity

Struct RetainedDirectoryIdentity 

Source
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

Source

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.

Source

pub fn identity(&self) -> &DirectoryFilesystemIdentity

Return the canonical identity captured from the retained handle.

Source

pub fn as_file(&self) -> &File ⓘ

Borrow the exact retained directory file for capability-based consumers.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for RetainedDirectoryIdentity

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.