pub struct PHash(/* private fields */);Expand description
A 64-bit perceptual hash derived from DCT coefficients.
Implementations§
Source§impl PHash
impl PHash
Sourcepub fn hamming_distance(self, other: Self) -> u32
pub fn hamming_distance(self, other: Self) -> u32
Hamming distance between two hashes (number of differing bits).
Sourcepub fn similarity(self, other: Self) -> f64
pub fn similarity(self, other: Self) -> f64
Similarity in range [0.0, 1.0].
1.0 = identical, 0.0 = maximally different.
Sourcepub fn is_near_duplicate(self, other: Self) -> bool
pub fn is_near_duplicate(self, other: Self) -> bool
Returns true if the two hashes are considered near-duplicates.
The default threshold is Hamming distance ≤ 10 (≈84 % similarity).
Sourcepub fn within_distance(self, other: Self, max_distance: u32) -> bool
pub fn within_distance(self, other: Self, max_distance: u32) -> bool
Returns true if Hamming distance is within max_distance.
Sourcepub fn from_hex(s: &str) -> DedupResult<Self>
pub fn from_hex(s: &str) -> DedupResult<Self>
Parse from hex string.
§Errors
Returns an error if the string is not a valid 16-character hex value.
Trait Implementations§
impl Copy for PHash
impl Eq for PHash
impl StructuralPartialEq for PHash
Auto Trait Implementations§
impl Freeze for PHash
impl RefUnwindSafe for PHash
impl Send for PHash
impl Sync for PHash
impl Unpin for PHash
impl UnsafeUnpin for PHash
impl UnwindSafe for PHash
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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