Skip to main content

PathResolver

Struct PathResolver 

Source
pub struct PathResolver<'a> { /* private fields */ }
Expand description

Resolves current on-disk paths from file IDs on an NTFS/ReFS volume.

Use PathResolver::new to configure and construct an instance:

use usn_journal_rs::{volume::Volume, path::PathResolver};

let volume = Volume::from_drive_letter('C').unwrap();

// Default resolver — live syscall resolution without caching:
let resolver = PathResolver::new(&volume);

// Opt into caching for a stable directory tree:
let resolver = PathResolver::new(&volume).with_directory_cache(8_192);

// Disable the directory cache entirely (pass 0):
let resolver = PathResolver::new(&volume).with_directory_cache(0);

resolve_path takes &self: the directory cache and scratch buffer are held behind interior mutability, so a single resolver can be shared across an iteration loop without a mut binding. PathResolver is intentionally !Sync because that interior state is not synchronized.

Implementations§

Source§

impl<'a> PathResolver<'a>

Source

pub fn new(volume: &'a Volume) -> Self

Create an uncached resolver for the given volume.

Use Self::with_directory_cache to opt into caching for stable trees.

This resolver is intended for live/current path resolution against the mounted volume.

Source

pub fn new_with_cache(volume: &'a Volume) -> Self

Create a resolver with the historical 4096-entry directory cache. Only use caching while the directory tree is stable.

Source

pub fn with_directory_cache(self, capacity: usize) -> Self

Set the directory path cache capacity.

Pass a positive capacity to enable (or resize) the cache; pass 0 to disable it entirely. When the cache is disabled, each directory lookup falls back to direct OpenFileById syscalls.

Caching is disabled by default. Cached paths are not invalidated when directories move or ancestors are renamed. Only enable caching while the directory tree is stable; rebuild the cache after topology changes.

Source

pub fn resolve_path<E: PathResolvableEntry + ?Sized>( &self, entry: &E, ) -> Option<PathBuf>

Resolve entry to its current on-disk path, using the directory cache when configured and falling back to OpenFileById syscalls.

Takes &self: the cache and scratch buffer are updated through interior mutability, so the same resolver can be reused across an iterator without a mut binding.

Standard 64-bit NTFS IDs and extended 128-bit IDs (for example ReFS USN_RECORD_V3 entries) are both resolved via the live volume.

Source

pub fn try_resolve_path<E: PathResolvableEntry + ?Sized>( &self, entry: &E, ) -> UsnResult<PathBuf>

Resolve a path while preserving the underlying OS failure. Tries the parent first, then the entry itself. If both fail, returns the entry lookup error. Successful parent lookup uses the supplied leaf name.

Trait Implementations§

Source§

impl<'a> Debug for PathResolver<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for PathResolver<'a>

§

impl<'a> !RefUnwindSafe for PathResolver<'a>

§

impl<'a> !Send for PathResolver<'a>

§

impl<'a> !Sync for PathResolver<'a>

§

impl<'a> Unpin for PathResolver<'a>

§

impl<'a> UnsafeUnpin for PathResolver<'a>

§

impl<'a> UnwindSafe for PathResolver<'a>

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, 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.