pub struct HashStore { /* private fields */ }Expand description
An in-memory hash store that maps digests to file entries.
Supports fast lookup by digest and retrieval of duplicate groups.
Implementations§
Source§impl HashStore
impl HashStore
Sourcepub fn with_capacity(cap: usize) -> Self
pub fn with_capacity(cap: usize) -> Self
Create a hash store with pre-allocated capacity.
Sourcepub fn unique_count(&self) -> usize
pub fn unique_count(&self) -> usize
Return the number of unique digests.
Sourcepub fn duplicate_groups(&self) -> Vec<(&str, &[HashEntry])>
pub fn duplicate_groups(&self) -> Vec<(&str, &[HashEntry])>
Return all digest groups that have more than one entry (duplicates).
Sourcepub fn duplicate_count(&self) -> usize
pub fn duplicate_count(&self) -> usize
Return the number of duplicate entries (entries beyond the first in each group).
Sourcepub fn duplicate_bytes(&self) -> u64
pub fn duplicate_bytes(&self) -> u64
Return the total file size of all duplicate entries.
Sourcepub fn remove(&mut self, digest: &str) -> Vec<HashEntry>
pub fn remove(&mut self, digest: &str) -> Vec<HashEntry>
Remove all entries for a given digest. Returns the removed entries.
Sourcepub fn digests(&self) -> impl Iterator<Item = &str>
pub fn digests(&self) -> impl Iterator<Item = &str>
Return an iterator over all unique digests.
Sourcepub fn dedup_ratio(&self) -> f64
pub fn dedup_ratio(&self) -> f64
Return deduplication ratio as a fraction.
1.0 means no duplicates, lower means more duplication.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HashStore
impl RefUnwindSafe for HashStore
impl Send for HashStore
impl Sync for HashStore
impl Unpin for HashStore
impl UnsafeUnpin for HashStore
impl UnwindSafe for HashStore
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