pub struct DeltaDeduplicator { /* private fields */ }Expand description
Delta deduplicator using rolling hash and KMP.
Orchestrates the two-phase deduplication approach:
- Rolling hash for fast filtering
- KMP for exact verification
§Example
ⓘ
let mut dedup = DeltaDeduplicator::new();
// Add accumulated content
dedup.add_accumulated("Hello World");
// Check if a delta is a duplicate
if let Some(new_portion) = dedup.extract_new_content("Hello World!") {
// "!" is the new portion
assert_eq!(new_portion, "!");
}Implementations§
Source§impl DeltaDeduplicator
impl DeltaDeduplicator
Sourcepub fn is_likely_snapshot(delta: &str, accumulated: &str) -> bool
pub fn is_likely_snapshot(delta: &str, accumulated: &str) -> bool
Check if delta is likely a snapshot using rolling hash only.
This is a faster O(n) check that may have false positives due to
hash collisions. Use extract_new_content for verified results.
§Arguments
delta- The incoming delta to checkaccumulated- The previously accumulated content
§Returns
true- Delta may be a snapshot (hash matches)false- Delta is definitely not a snapshot (hash doesn’t match)
Sourcepub fn is_likely_snapshot_with_thresholds(
delta: &str,
accumulated: &str,
) -> bool
pub fn is_likely_snapshot_with_thresholds( delta: &str, accumulated: &str, ) -> bool
Check if delta is likely a snapshot with strong overlap detection.
This is an enhanced version of is_likely_snapshot that applies
strong overlap thresholds to prevent false positives on intentional
repetitions.
§Strong Overlap Detection
This method only returns true when:
- The overlap meets minimum character count threshold (default: 30 chars)
- The overlap meets minimum ratio threshold (default: 50% of delta)
- The overlap ends at a safe boundary (whitespace/punctuation/newline)
- Short chunks (< 20 chars) are only deduped if exact match
§Arguments
delta- The incoming delta to checkaccumulated- The previously accumulated content
§Returns
true- Delta is a snapshot meeting strong overlap criteriafalse- Delta is either genuine or overlap is too weak
Sourcepub fn extract_new_content_with_thresholds<'a>(
delta: &'a str,
accumulated: &str,
) -> Option<&'a str>
pub fn extract_new_content_with_thresholds<'a>( delta: &'a str, accumulated: &str, ) -> Option<&'a str>
Extract new content from a snapshot with strong overlap detection.
This is an enhanced version of extract_new_content that only extracts
new content when the overlap meets strong overlap thresholds.
§Arguments
delta- The incoming delta to checkaccumulated- The previously accumulated content
§Returns
Some(new_portion)- The overlap meets thresholds, returns new portionNone- The overlap is too weak or not a snapshot
Trait Implementations§
Source§impl Clone for DeltaDeduplicator
impl Clone for DeltaDeduplicator
Source§fn clone(&self) -> DeltaDeduplicator
fn clone(&self) -> DeltaDeduplicator
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DeltaDeduplicator
impl Debug for DeltaDeduplicator
Source§impl Default for DeltaDeduplicator
impl Default for DeltaDeduplicator
Source§fn default() -> DeltaDeduplicator
fn default() -> DeltaDeduplicator
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for DeltaDeduplicator
impl RefUnwindSafe for DeltaDeduplicator
impl Send for DeltaDeduplicator
impl Sync for DeltaDeduplicator
impl Unpin for DeltaDeduplicator
impl UnwindSafe for DeltaDeduplicator
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> 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>
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