pub struct MultiHashFingerprint { /* private fields */ }Expand description
A multi-algorithm fingerprint containing hashes from multiple perceptual algorithms.
Provides enhanced similarity detection by combining results from multiple hash algorithms with weighted combination for improved accuracy.
§Binary layout
#[repr(C)] with no padding bytes (536 bytes total: 32 + 3 × 168). Implements
bytemuck::Pod / bytemuck::Zeroable for zero-copy cast to &[u8].
See ImageFingerprint for an example.
Stable layout is enforced at compile time via a const _ size assertion;
any accidental layout drift fails the build.
Copy is derived for bytemuck::Pod compatibility; move-by-value silently
memcpys 536 bytes. Prefer borrowing (&MultiHashFingerprint) in hot loops.
Implementations§
Source§impl MultiHashFingerprint
impl MultiHashFingerprint
Sourcepub fn exact_hash(&self) -> &[u8; 32]
pub fn exact_hash(&self) -> &[u8; 32]
Returns the BLAKE3 hash of the original image bytes.
Sourcepub const fn format_version() -> u32
pub const fn format_version() -> u32
Returns the on-disk format version this fingerprint was computed under.
Equal to crate::FORMAT_VERSION. Persist alongside fingerprint bytes
(or in a sidecar manifest) and refuse comparison across mismatched
versions to guard against algorithm-version drift.
Sourcepub fn ahash(&self) -> &ImageFingerprint
pub fn ahash(&self) -> &ImageFingerprint
Returns the AHash-based fingerprint.
Sourcepub fn phash(&self) -> &ImageFingerprint
pub fn phash(&self) -> &ImageFingerprint
Returns the PHash-based fingerprint.
Sourcepub fn dhash(&self) -> &ImageFingerprint
pub fn dhash(&self) -> &ImageFingerprint
Returns the DHash-based fingerprint.
Sourcepub fn get(&self, algorithm: HashAlgorithm) -> &ImageFingerprint
pub fn get(&self, algorithm: HashAlgorithm) -> &ImageFingerprint
Returns the fingerprint for a specific algorithm.
Sourcepub fn compare(&self, other: &MultiHashFingerprint) -> Similarity
pub fn compare(&self, other: &MultiHashFingerprint) -> Similarity
Compares two multi-hash fingerprints using the default weighted combination.
Equivalent to compare_with_config called
with MultiHashConfig::default():
- 10%
AHash/ 60%PHash/ 30%DHashper-algorithm blend - Within each algorithm, 40% global hash + 60% block-level hashes
- Block distance threshold of 32 (Hamming, out of 64)
Use compare_with_config to tune any of these.
Sourcepub fn compare_with_threshold(
&self,
other: &MultiHashFingerprint,
block_threshold: u32,
) -> Similarity
pub fn compare_with_threshold( &self, other: &MultiHashFingerprint, block_threshold: u32, ) -> Similarity
Compares two multi-hash fingerprints with a custom block distance threshold.
§Arguments
other- The fingerprint to compare againstblock_threshold- Maximum Hamming distance for a block to count as a match (0-64). Lower = stricter (fewer blocks qualify), higher = looser. Default is 32.
Sourcepub fn compare_with_config(
&self,
other: &MultiHashFingerprint,
config: &MultiHashConfig,
) -> Similarity
pub fn compare_with_config( &self, other: &MultiHashFingerprint, config: &MultiHashConfig, ) -> Similarity
Compares two multi-hash fingerprints using a fully configurable weight and threshold set.
All knobs from MultiHashConfig are honored; defaults reproduce
compare. See MultiHashConfig for examples.
Sourcepub fn is_similar(&self, other: &MultiHashFingerprint, threshold: f32) -> bool
pub fn is_similar(&self, other: &MultiHashFingerprint, threshold: f32) -> bool
Checks if this fingerprint is similar to another within a threshold.
Uses the weighted combination score from compare().
§Panics
Panics in debug mode if threshold is not in [0.0, 1.0]. In release mode, out-of-range or NaN thresholds return false.
Trait Implementations§
Source§impl Clone for MultiHashFingerprint
impl Clone for MultiHashFingerprint
Source§fn clone(&self) -> MultiHashFingerprint
fn clone(&self) -> MultiHashFingerprint
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MultiHashFingerprint
impl Debug for MultiHashFingerprint
Source§impl<'de> Deserialize<'de> for MultiHashFingerprint
impl<'de> Deserialize<'de> for MultiHashFingerprint
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Hash for MultiHashFingerprint
impl Hash for MultiHashFingerprint
Source§impl PartialEq for MultiHashFingerprint
impl PartialEq for MultiHashFingerprint
Source§fn eq(&self, other: &MultiHashFingerprint) -> bool
fn eq(&self, other: &MultiHashFingerprint) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for MultiHashFingerprint
impl Serialize for MultiHashFingerprint
impl Copy for MultiHashFingerprint
impl Eq for MultiHashFingerprint
impl Pod for MultiHashFingerprint
impl StructuralPartialEq for MultiHashFingerprint
Auto Trait Implementations§
impl Freeze for MultiHashFingerprint
impl RefUnwindSafe for MultiHashFingerprint
impl Send for MultiHashFingerprint
impl Sync for MultiHashFingerprint
impl Unpin for MultiHashFingerprint
impl UnsafeUnpin for MultiHashFingerprint
impl UnwindSafe for MultiHashFingerprint
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> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.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