pub struct PersistentFingerprintCache { /* private fields */ }Expand description
Cross-session persistent cache mapping file paths to their fingerprints.
Entries are keyed by path string.
Implementations§
Source§impl PersistentFingerprintCache
impl PersistentFingerprintCache
Sourcepub fn load(cache_path: PathBuf) -> Result<Self>
pub fn load(cache_path: PathBuf) -> Result<Self>
Load a cache from cache_path.
Returns an empty cache (rather than an error) if the file does not
exist. Returns Err only on genuine I/O or parse failures.
§Errors
Returns an io::Error if the file exists but cannot be read or parsed.
Sourcepub fn save(&self) -> Result<()>
pub fn save(&self) -> Result<()>
Save the cache to disk atomically (write temp → rename).
§Errors
Returns an io::Error if writing or renaming fails.
Sourcepub fn insert(&mut self, entry: CachedEntry)
pub fn insert(&mut self, entry: CachedEntry)
Insert or update a CachedEntry.
Sourcepub fn remove(&mut self, path: &str) -> Option<CachedEntry>
pub fn remove(&mut self, path: &str) -> Option<CachedEntry>
Remove the entry for path, returning it if it existed.
Sourcepub fn get(&self, path: &str) -> Option<&CachedEntry>
pub fn get(&self, path: &str) -> Option<&CachedEntry>
Look up a cached entry by file path without freshness checking.
Use get_valid to validate against on-disk state.
Sourcepub fn get_valid(&mut self, path: &str) -> Option<&CachedEntry>
pub fn get_valid(&mut self, path: &str) -> Option<&CachedEntry>
Look up a cached entry, validating that the stored BLAKE3 digest still matches the current file.
Reads the actual file to recompute its BLAKE3 hash. Returns None if:
- The entry is not in the cache.
- The file does not exist.
- The digest has changed (file was modified).
Updates the internal hit/miss counters.
Sourcepub fn hits(&self) -> u64
pub fn hits(&self) -> u64
Return the number of cache hits since the cache was loaded or last reset.
Sourcepub fn misses(&self) -> u64
pub fn misses(&self) -> u64
Return the number of cache misses since the cache was loaded or last reset.
Sourcepub fn hit_rate(&self) -> f64
pub fn hit_rate(&self) -> f64
Return the hit rate (0.0 – 1.0). Returns 0.0 if no lookups have been made.
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Reset hit/miss counters.
Sourcepub fn evict_missing(&mut self) -> usize
pub fn evict_missing(&mut self) -> usize
Evict all entries whose source file no longer exists on disk.
Returns the number of entries evicted.
Sourcepub fn evict_stale(&mut self) -> usize
pub fn evict_stale(&mut self) -> usize
Evict all entries that are stale (file modified since caching).
Recomputes BLAKE3 hashes for all cached files. Entries are removed when the digest no longer matches. Returns the number of entries evicted.
Sourcepub fn merge_from(&mut self, other: &Self)
pub fn merge_from(&mut self, other: &Self)
Merge entries from other into this cache.
Entries in other overwrite entries with the same path in self.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&String, &CachedEntry)>
pub fn iter(&self) -> impl Iterator<Item = (&String, &CachedEntry)>
Return an iterator over all cached entries.
Trait Implementations§
Source§impl Clone for PersistentFingerprintCache
impl Clone for PersistentFingerprintCache
Source§fn clone(&self) -> PersistentFingerprintCache
fn clone(&self) -> PersistentFingerprintCache
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PersistentFingerprintCache
impl RefUnwindSafe for PersistentFingerprintCache
impl Send for PersistentFingerprintCache
impl Sync for PersistentFingerprintCache
impl Unpin for PersistentFingerprintCache
impl UnsafeUnpin for PersistentFingerprintCache
impl UnwindSafe for PersistentFingerprintCache
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more