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>
impl<'a> PathResolver<'a>
Sourcepub fn new(volume: &'a Volume) -> Self
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.
Sourcepub fn new_with_cache(volume: &'a Volume) -> Self
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.
Sourcepub fn with_directory_cache(self, capacity: usize) -> Self
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.
Sourcepub fn resolve_path<E: PathResolvableEntry + ?Sized>(
&self,
entry: &E,
) -> Option<PathBuf>
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.
Sourcepub fn try_resolve_path<E: PathResolvableEntry + ?Sized>(
&self,
entry: &E,
) -> UsnResult<PathBuf>
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.