pub struct DedupSessionCache { /* private fields */ }Expand description
Session-scoped cache for decoded thumbnails and fingerprints.
Keys are the FNV-1a hash of the file path bytes. The cache is bounded
to capacity entries; excess entries are evicted using LRU order tracked
by lru_order.
Implementations§
Source§impl DedupSessionCache
impl DedupSessionCache
Sourcepub fn get_or_compute_phash(
&mut self,
path: &Path,
compute: impl FnOnce() -> DedupResult<u64>,
) -> DedupResult<u64>
pub fn get_or_compute_phash( &mut self, path: &Path, compute: impl FnOnce() -> DedupResult<u64>, ) -> DedupResult<u64>
Look up or compute the pHash for path.
On cache hit where the mtime matches, returns the cached value.
On mtime mismatch or absence, calls compute, stores the result, and
returns it.
Sourcepub fn save_to_file(&self, path: &Path) -> DedupResult<()>
pub fn save_to_file(&self, path: &Path) -> DedupResult<()>
Save the cache to a JSON file.
Sourcepub fn load_from_file(path: &Path) -> DedupResult<Self>
pub fn load_from_file(path: &Path) -> DedupResult<Self>
Load a previously saved cache from a JSON file.
The LRU order is reset (all entries treated as equally recent).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DedupSessionCache
impl RefUnwindSafe for DedupSessionCache
impl Send for DedupSessionCache
impl Sync for DedupSessionCache
impl Unpin for DedupSessionCache
impl UnsafeUnpin for DedupSessionCache
impl UnwindSafe for DedupSessionCache
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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