Struct ssdeep::FuzzyHashData

source ·
#[repr(align(8))]
pub struct FuzzyHashData<const S1: usize, const S2: usize, const NORM: bool>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,{ /* private fields */ }
Expand description

An efficient fixed size fuzzy hash representation.

Fuzzy Hash Internals

A fuzzy hash consists of four parts:

  1. Block size (reciprocal of average piece-splitting probability per byte)

  2. Block hash 1. 6-bit hash per “piece”, variable-length up to BlockHash::FULL_SIZE.

    The average piece-splitting probability is given as 1/block_size.

  3. Block hash 2. 6-bit hash per “piece”, variable-length up to either

    The average piece-splitting probability is given as 1/block_size/2).

  4. (optional) The input file name, which is ignored by the parser on this type.

This struct stores first three parts of a fuzzy hash.

You can see the following figure for an example:

196608:DfiQF5UWAC2qctjBemsqz7yHlHr4bMCE2J8Y:jBp/Fqz7mlHZCE2J8Y,"/usr/local/bin/rustc"
\____/|\__________________________________/|\________________/|\____________________/
 |    |            Block hash 1            |   Block hash 2   | File name (optional)
 |    |                                    |                  |
 |    +-- (sep:colon)                      +-- (sep:colon)    +-- (sep,comma (optional))
 |
 +-- Block size

Block Size

In the example above, 1 / 196 608 is the average probability for piece-splitting per byte on the block hash 1. On the block hash 2, the probability is 1 / 393 216 per byte, half of the probability on the block hash 1.

Since ssdeep uses a 32-bit hash function to decide whether to perform a piece-splitting, this probability will get inaccurate as the block size gets larger.

There is an important property of the block size: all valid block sizes can be represented as BlockSize::MIN * 2n (n ≧ 0).

In this crate, the block size is stored as n (the base-2 logarithm form of the block size) for higher efficiency. log_block_size() method returns this raw representation. If you need an actual block size as used in the string representation, block_size() can be used instead.

Block Hashes

A fuzzy hash has two block hashes (1 and 2).

They are variable-length fields that store an array of 6-bit “piece” hash values (represented as Base64 characters in the string representation and internally stored as Base64 indices).

Relations with Block Size

The reason a fuzzy hash having two block hashes is, to enable comparing fuzzy hashes with similar block sizes (but not too far).

In principle, we can only compare block hashes with the same block size directly. Think following fuzzy hash for example:

6144:SIsMYod+X3oI+YnsMYod+X3oI+YZsMYod+X3oI+YLsMYod+X3oI+YQ:Z5d+X395d+X3X5d+X315d+X3+
     \____________________________________________________/ \_______________________/
      Block hash 1                                                      Block hash 2
      (effective block size: 6144)                      (effective block size: 12288)
                                                               [*] 12288 == 6144 * 2

You can easily compare it with another fuzzy hash with the same block size (but actual block hash similarity scoring only occurs after checking common substring).

Unaligned:
[A] 6144:SIsMYod+X3oI+YnsMYod+X3oI+YZsMYod+X3oI+YLsMYod+X3oI+YQ:Z5d+X395d+X3X5d+X315d+X3+
[B] 6144:SAsMYod+X3oI+YEWnnsMYod+X3oI+Y5sMYod+X3oI+YLsMYod+X3oI+YQ:H5d+X36WnL5d+X3v5d+X315d+X3+

Aligned:
[A] 6144:SIsMYod+X3oI+YnsMYod+X3oI+YZsMYod+X3oI+YLsMYod+X3oI+YQ   :Z5d+X395d+X3X5d+X315d+X3+
[B] 6144:SAsMYod+X3oI+YEWnnsMYod+X3oI+Y5sMYod+X3oI+YLsMYod+X3oI+YQ:H5d+X36WnL5d+X3v5d+X315d+X3+
         \_______________________________________________________/ \__________________________/
                               Comparison 1                                Comparison 2
                      (score([A1], [B1], 6144) = 94)            (score([A2], [B2], 12288) = 85)

score_final([A], [B], 6144) = max(94, 85) = 94

The final similarity score is the maximum of two block hash comparisons (note that the score function on small block sizes will cap the score to prevent exaggeration of matches).

If you have two fuzzy hashes with different block sizes but they are near enough, we can still perform a block hash comparison.

Unaligned:
[A] 3072:S+IiyfkMY+BES09JXAnyrZalI+YuyfkMY+BES09JXAnyrZalI+YQ:S+InsMYod+X3oI+YLsMYod+X3oI+YQ
[B] 6144:SIsMYod+X3oI+YnsMYod+X3oI+YZsMYod+X3oI+YLsMYod+X3oI+YQ:Z5d+X395d+X3X5d+X315d+X3+
[C] 12288:Z5d+X3pz5d+X3985d+X3X5d+X315d+X3+:1+Jr+d++H+5+e

Aligned:
[A] 3072 :S+IiyfkMY+BES09JXAnyrZalI+YuyfkMY+BES09JXAnyrZalI+YQ:S+InsMYod+X3oI+YLsMYod+X3oI+YQ
[B] 6144 :                                                     SIsMYod+X3oI+YnsMYod+X3oI+YZsMYod+X3oI+YLsMYod+X3oI+YQ:Z5d+X395d+X3X5d+X315d+X3+
[C] 12288:                                                                                                            Z5d+X3pz5d+X3985d+X3X5d+X315d+X3+:1+Jr+d++H+5+e
          \__________________________________________________/ \____________________________________________________/ \_______________________________/ \___________/
           Eff.B.S.=3072                                        Eff.B.S.=6144                                          Eff.B.S.=12288                    Eff.B.S.=24576
                                                                Comparison between [A2] and [B1]                       Comparison between [B2] and [C1]
                                                                (score([A2], [B1], 6144) = 72)                         (score([B2], [C1], 12288) = 88)

score_final([A], [B], 3072) = score([A2], [B1],  6144) = 72
score_final([B], [C], 6144) = score([B2], [C1], 12288) = 88
score_final([A], [C], 3072) = 0 (since there's no block hashes to compare)

Such cases are handled with BlockSizeRelation and BlockSize utility functions. We can outline the relation in the table below. Note that each block size is denoted as “Actual block size (block size in base-2 logarithm)”.

Left (lhs)Right (rhs)Relation
3072 (10)6144 (11)NearLt
6144 (11)3072 (10)NearGt
6144 (11)6144 (11)NearEq
6144 (11)12288 (12)NearLt
12288 (12)6144 (11)NearGt
3072 (10)12288 (12)Far

On highly optimized clustering applications, being aware of the block size relation will be crucial.

See also: BlockSizeRelation

Normalization

To prevent exaggerating the comparison score from repeating patterns, ssdeep processes each block hash before comparison so that a sequence consisting of the same character longer than BlockHash::MAX_SEQUENCE_SIZE cannot exist.

For instance, after processing a block hash 122333444455555, it is converted to 122333444555 (four 4s and five 5s are shortened into three 4s and three 5s because BlockHash::MAX_SEQUENCE_SIZE is defined to be three (3)).

In this crate, this process is called normalization.

ssdeep normally generates (as well as Generator) not normalized, raw fuzzy hashes. So, making a distinction between normalized and raw forms are important.

Truncation

ssdeep normally generates (as well as Generator) truncated fuzzy hashes. In the truncated fuzzy hash, length of block hash 2 is limited to BlockHash::HALF_SIZE, half of the maximum length of block hash 1 (BlockHash::FULL_SIZE).

While libfuzzy allows generating non-truncated, long fuzzy hashes, they are typically useless. So, most operations are performed in short, truncated fuzzy hashes by default. Short variants of FuzzyHashData is smaller than longer variants so it can be used to reduce memory footprint.

Implementations§

source§

impl<const S1: usize, const S2: usize> FuzzyHashData<S1, S2, true>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

Additional implementation for normalized fuzzy hashes, enabling comparison between two fuzzy hashes directly.

source

pub fn compare(&self, other: impl AsRef<Self>) -> u32

Compare two fuzzy hashes and retrieves the similarity score.

source

pub unsafe fn compare_unequal_unchecked(&self, other: impl AsRef<Self>) -> u32

Available on crate feature unsafe only.

Compare two fuzzy hashes assuming both are different.

Safety
  • self and other must be different.

If the condition above is not satisfied, it will return a meaningless score.

source

pub fn compare_unequal(&self, other: impl AsRef<Self>) -> u32

SLOW: Compare two fuzzy hashes assuming both are different.

Usage Constraints
  • self and other must be different.
Performance Consideration

This method’s performance is not good enough (because of constraint checking).

Use those instead:

source§

impl<const S1: usize, const S2: usize, const NORM: bool> FuzzyHashData<S1, S2, NORM>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

Implementation for all variants of fuzzy hashes.

Constants and methods below are available on all variants of fuzzy hashes.

source

pub const MAX_BLOCK_HASH_SIZE_1: usize = S1

The maximum size of the block hash 1.

This value is always BlockHash::FULL_SIZE.

source

pub const MAX_BLOCK_HASH_SIZE_2: usize = S2

The maximum size of the block hash 2.

This value is either BlockHash::HALF_SIZE or BlockHash::FULL_SIZE.

source

pub const IS_NORMALIZED_FORM: bool = NORM

Denotes whether the fuzzy type only contains a normalized form.

source

pub const IS_LONG_FORM: bool = _

Denotes whether the fuzzy type can contain a non-truncated fuzzy hash.

It directly corresponds to MAX_BLOCK_HASH_SIZE_2.

source

pub fn new() -> Self

Creates a new fuzzy hash object with empty contents.

This is equivalent to the fuzzy hash string 3::.

source

pub unsafe fn init_from_internals_raw_unchecked( &mut self, log_block_size: u8, block_hash_1: &[u8; S1], block_hash_2: &[u8; S2], block_hash_1_len: u8, block_hash_2_len: u8 )

Available on crate feature unsafe only.

Initialize the fuzzy hash object with internal contents (raw).

Safety
  • Valid range of block_hash_1 and block_hash_2 must consist of valid Base64 indices.
  • Invalid ranges of block_hash_1 and block_hash_2 must be filled with zeroes.
  • block_hash_1_len and block_hash_2_len must be valid.
  • log_block_size must hold a valid base-2 logarithm form of a block size.
  • On the normalized variant, contents of block_hash_1 and block_hash_2 must be normalized.

If they are not satisfied, the resulting object is corrupted.

source

pub fn init_from_internals_raw( &mut self, log_block_size: u8, block_hash_1: &[u8; S1], block_hash_2: &[u8; S2], block_hash_1_len: u8, block_hash_2_len: u8 )

Initialize the fuzzy hash object with internal contents (raw).

Because this function assumes that you know the fuzzy hash internals, it panics when you fail to satisfy fuzzy hash constraints.

Usage Constraints
  • Valid range of block_hash_1 and block_hash_2 must consist of valid Base64 indices.
  • Invalid ranges of block_hash_1 and block_hash_2 must be filled with zeroes.
  • block_hash_1_len and block_hash_2_len must be valid.
  • log_block_size must hold a valid base-2 logarithm form of a block size.
  • On the normalized variant, contents of block_hash_1 and block_hash_2 must be normalized.
source

pub unsafe fn new_from_internals_raw_unchecked( log_block_size: u8, block_hash_1: &[u8; S1], block_hash_2: &[u8; S2], block_hash_1_len: u8, block_hash_2_len: u8 ) -> Self

Available on crate feature unsafe only.

Creates a new fuzzy hash object with internal contents (raw).

Safety
  • Valid range of block_hash_1 and block_hash_2 must consist of valid Base64 indices.
  • Invalid ranges of block_hash_1 and block_hash_2 must be filled with zeroes.
  • block_hash_1_len and block_hash_2_len must be valid.
  • log_block_size must hold a valid base-2 logarithm form of a block size.
  • On the normalized variant, contents of block_hash_1 and block_hash_2 must be normalized.

If they are not satisfied, the resulting object is corrupted.

source

pub fn new_from_internals_raw( log_block_size: u8, block_hash_1: &[u8; S1], block_hash_2: &[u8; S2], block_hash_1_len: u8, block_hash_2_len: u8 ) -> Self

Creates a new fuzzy hash object with internal contents (raw).

Because this function assumes that you know the fuzzy hash internals, it panics when you fail to satisfy fuzzy hash constraints.

Usage Constraints
  • Valid range of block_hash_1 and block_hash_2 must consist of valid Base64 indices.
  • Invalid ranges of block_hash_1 and block_hash_2 must be filled with zeroes.
  • block_hash_1_len and block_hash_2_len must be valid.
  • log_block_size must hold a valid base-2 logarithm form of a block size.
  • On the normalized variant, contents of block_hash_1 and block_hash_2 must be normalized.
source

pub unsafe fn new_from_internals_unchecked( block_size: u32, block_hash_1: &[u8], block_hash_2: &[u8] ) -> Self

Available on crate feature unsafe only.

Creates a new fuzzy hash object with internal contents.

Safety
  • block_hash_1 and block_hash_2 must have valid lengths.
  • Elements of block_hash_1 and block_hash_2 must consist of valid Base64 indices.
  • block_size must hold a valid block size.
  • On the normalized variant, contents of block_hash_1 and block_hash_2 must be normalized.

If they are not satisfied, the resulting object will be corrupted.

source

pub fn new_from_internals( block_size: u32, block_hash_1: &[u8], block_hash_2: &[u8] ) -> Self

Creates a new fuzzy hash object with internal contents.

Because this function assumes that you know the fuzzy hash internals, it panics when you fail to satisfy fuzzy hash constraints.

Usage Constraints
  • block_hash_1 and block_hash_2 must have valid lengths.
  • Elements of block_hash_1 and block_hash_2 must consist of valid Base64 indices.
  • block_size must hold a valid block size.
  • On the normalized variant, contents of block_hash_1 and block_hash_2 must be normalized.
source

pub fn log_block_size(&self) -> u8

The base-2 logarithm form of the block size.

See also: “Block Size” section of FuzzyHashData

source

pub fn block_size(&self) -> u32

The block size of the fuzzy hash.

source

pub fn block_hash_1(&self) -> &[u8]

A reference to the block hash 1.

Safety Tips

You cannot modify a fuzzy hash while block hashes are borrowed through block_hash_1 or block_hash_2.

let mut hash = ssdeep::FuzzyHash::from_str("3:aaaa:bbbb").unwrap();
let bh1 = hash.block_hash_1();
hash.normalize_in_place(); // <- ERROR: because block hash 1 is borrowed.
// If normalize_in_place succeeds, bh1 will hold an invalid slice
// because block hash 1 is going to be length 3 after the normalization.
assert_eq!(bh1.len(), 4);
source

pub fn block_hash_1_as_array(&self) -> &[u8; S1]

A reference to the block hash 1 (in fixed-size array).

Elements that are not a part of the block hash are filled with zeroes.

See also: block_hash_1

source

pub fn block_hash_1_len(&self) -> usize

The length of the block hash 1.

source

pub fn block_hash_2(&self) -> &[u8]

A reference to the block hash 2.

Safety Tips

You cannot modify a fuzzy hash while block hashes are borrowed through block_hash_1 or block_hash_2.

let mut hash = ssdeep::FuzzyHash::from_str("3:aaaa:bbbb").unwrap();
let bh2 = hash.block_hash_2();
hash.normalize_in_place(); // <- ERROR: because block hash 2 is borrowed.
// If normalize_in_place succeeds, bh2 will hold an invalid slice
// because block hash 2 is going to be length 3 after the normalization.
assert_eq!(bh2.len(), 4);
source

pub fn block_hash_2_as_array(&self) -> &[u8; S2]

A reference to the block hash 2 (in fixed-size array).

Elements that are not a part of the block hash are filled with zeroes.

See also: block_hash_2

source

pub fn block_hash_2_len(&self) -> usize

The length of the block hash 2.

source

pub fn len_in_str(&self) -> usize

The length of this fuzzy hash in the string representation.

This is the exact size (bytes and characters) required to store the string representation corresponding this fuzzy hash object.

source

pub const MAX_LEN_IN_STR: usize = _

The maximum length in the string representation.

source

pub fn to_string(&self) -> String

Available on crate feature alloc only.

Converts the fuzzy hash to the string.

source

pub fn store_into_bytes( &self, buffer: &mut [u8] ) -> Result<(), FuzzyHashOperationError>

Store the string representation of the fuzzy hash into the bytes. Returns whether the operation has succeeded.

The only case this function will fail (returns an Err) is, when buffer does not have enough size to store string representation of the fuzzy hash.

Required size of the buffer is len_in_str() bytes. This size is exact.

source

pub fn from_bytes(str: &[u8]) -> Result<Self, ParseError>

Parse a fuzzy hash from given bytes (a slice of u8) of a string representation.

source

pub fn normalize_in_place(&mut self)

Normalize the fuzzy hash in place.

After calling this method, self will be normalized.

See also: “Normalization” section of FuzzyHashData

source

pub fn is_valid(&self) -> bool

Performs full validity checking of the internal structure.

The primary purpose of this is debugging and it should always return true unless…

  1. There is a bug in this crate, corrupting this structure or
  2. A memory corruption is occurred somewhere else.

Because of its purpose, this method is not designed to be fast.

Note that, despite that it is only relevant to users when the unsafe feature is enabled but made public without any features because this method is not unsafe.

source

pub fn full_eq(&self, other: &Self) -> bool

Performs full equality checking of the internal structure.

While PartialEq::eq for this type is designed to be fast by ignoring non-block hash bytes, this method performs full equality checking, not ignoring “non-block hash” bytes.

The primary purpose of this is debugging and it should always return the same value as PartialEq::eq result unless…

  1. There is a bug in this crate, corrupting this structure or
  2. A memory corruption is occurred somewhere else.

Because of its purpose, this method is not designed to be fast.

Note that, despite that it is only relevant to users when the unsafe feature is enabled but made public without any features because this method is not unsafe.

source

pub fn compare_block_sizes( lhs: impl AsRef<Self>, rhs: impl AsRef<Self> ) -> BlockSizeRelation

Compare two base-2 logarithm forms of the block size values from given two fuzzy hashes to determine their block size relation.

source

pub fn is_block_sizes_near(lhs: impl AsRef<Self>, rhs: impl AsRef<Self>) -> bool

Checks whether two base-2 logarithm forms of the block size values from given two fuzzy hashes form a near relation.

source

pub fn is_block_sizes_near_eq( lhs: impl AsRef<Self>, rhs: impl AsRef<Self> ) -> bool

Checks whether two base-2 logarithm forms of the block size values from given two fuzzy hashes form a BlockSizeRelation::NearEq relation.

source

pub fn is_block_sizes_near_lt( lhs: impl AsRef<Self>, rhs: impl AsRef<Self> ) -> bool

Checks whether two base-2 logarithm forms of the block size values from given two fuzzy hashes form a BlockSizeRelation::NearLt relation.

source

pub fn is_block_sizes_near_gt( lhs: impl AsRef<Self>, rhs: impl AsRef<Self> ) -> bool

Checks whether two base-2 logarithm forms of the block size values from given two fuzzy hashes form a BlockSizeRelation::NearGt relation.

source

pub fn cmp_by_block_size(&self, other: &Self) -> Ordering

Compare two fuzzy hashes only by their block sizes.

source§

impl<const S1: usize, const S2: usize> FuzzyHashData<S1, S2, { _ }>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

Implementation of normalized fuzzy hashes.

Methods below are available on normalized fuzzy hashes (FuzzyHash or LongFuzzyHash).

source

pub fn from_raw_form(source: &FuzzyHashData<S1, S2, { _ }>) -> Self

Converts the fuzzy hash from a raw form, normalizing it.

source

pub fn to_raw_form(&self) -> FuzzyHashData<S1, S2, { _ }>

Converts the fuzzy hash to a raw form.

source

pub fn into_mut_raw_form(&self, dest: &mut FuzzyHashData<S1, S2, { _ }>)

Copy the fuzzy hash to another (output is a raw form).

source

pub fn normalize(&self) -> FuzzyHashData<S1, S2, { _ }>

Converts the fuzzy hash to a normalized form (with normalization).

In this normalized variant, this normalization is just a clone.

See also: “Normalization” section of FuzzyHashData

source

pub fn clone_normalized(&self) -> Self

Clones the fuzzy hash with normalization but without changing a type.

For a normalized fuzzy hash type, it always clones itself.

source

pub fn is_normalized(&self) -> bool

Returns whether the fuzzy hash is normalized.

For a normalized fuzzy hash type, it always returns true.

Note that this method is only for convenience purposes and checking whether a fuzzy hash is normalized does not usually improve the performance.

source§

impl<const S1: usize, const S2: usize> FuzzyHashData<S1, S2, { _ }>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

Implementation of non-normalized fuzzy hashes (in raw form).

Methods below are available on non-normalized fuzzy hashes (RawFuzzyHash or LongRawFuzzyHash).

source

pub fn from_normalized(source: &FuzzyHashData<S1, S2, { _ }>) -> Self

Converts the fuzzy hash from a normalized form.

source

pub fn normalize(&self) -> FuzzyHashData<S1, S2, { _ }>

Converts the fuzzy hash to a normalized form (with normalization).

In this raw form variant, it performs a normalization operation.

See also: “Normalization” section of FuzzyHashData

source

pub fn clone_normalized(&self) -> Self

Clones the fuzzy hash with normalization but without changing a type.

source

pub fn is_normalized(&self) -> bool

Returns whether the fuzzy hash is normalized.

For a non-normalized fuzzy hash type (in raw form), it checks whether the fuzzy hash is already normalized.

Note that this method is only for convenience purposes and checking whether a fuzzy hash is normalized does not usually improve the performance.

source§

impl<const NORM: bool> FuzzyHashData<{ BlockHash::FULL_SIZE }, { BlockHash::HALF_SIZE }, NORM>

Implementation of short fuzzy hashes.

Methods below are available on short (truncated) fuzzy hashes (FuzzyHash or RawFuzzyHash).

source

pub fn to_long_form( &self ) -> FuzzyHashData<{ BlockHash::FULL_SIZE }, { BlockHash::FULL_SIZE }, NORM>

Converts the fuzzy hash to a long form.

source

pub fn into_mut_long_form( &self, dest: &mut FuzzyHashData<{ BlockHash::FULL_SIZE }, { BlockHash::FULL_SIZE }, NORM> )

Copy the fuzzy hash to another (output is a long form).

source§

impl<const NORM: bool> FuzzyHashData<{ BlockHash::FULL_SIZE }, { BlockHash::FULL_SIZE }, NORM>

Implementation of long fuzzy hashes.

Methods below are available on long (non-truncated) fuzzy hashes (LongFuzzyHash or LongRawFuzzyHash).

source

pub fn from_short_form( source: &FuzzyHashData<{ BlockHash::FULL_SIZE }, { BlockHash::HALF_SIZE }, NORM> ) -> Self

Converts the fuzzy hash from a short, truncated form.

source

pub fn try_into_mut_short( &self, dest: &mut FuzzyHashData<{ BlockHash::FULL_SIZE }, { BlockHash::HALF_SIZE }, NORM> ) -> Result<(), FuzzyHashOperationError>

Tries to copy the fuzzy hash to another (output is a short form).

Trait Implementations§

source§

impl<const S1: usize, const S2: usize, const NORM: bool> AsRef<FuzzyHashData<S1, S2, NORM>> for FuzzyHashData<S1, S2, NORM>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

source§

fn as_ref(&self) -> &FuzzyHashData<S1, S2, NORM>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<const S1: usize, const S2: usize, const C1: usize, const C2: usize> AsRef<FuzzyHashData<S1, S2, true>> for FuzzyHashDualData<S1, S2, C1, C2>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes, RleBlockSizeForBlockHash<S1, C1>: ConstrainedRleBlockSizeForBlockHash, RleBlockSizeForBlockHash<S2, C2>: ConstrainedRleBlockSizeForBlockHash,

source§

fn as_ref(&self) -> &FuzzyHashData<S1, S2, true>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<const S1: usize, const S2: usize, const NORM: bool> Clone for FuzzyHashData<S1, S2, NORM>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

source§

fn clone(&self) -> FuzzyHashData<S1, S2, NORM>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<const S1: usize, const S2: usize, const NORM: bool> Debug for FuzzyHashData<S1, S2, NORM>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<const S1: usize, const S2: usize, const NORM: bool> Default for FuzzyHashData<S1, S2, NORM>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<const S1: usize, const S2: usize, const NORM: bool> Display for FuzzyHashData<S1, S2, NORM>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using a given formatter.

Safety

This method assumes that the fuzzy hash data is not broken.

Unlike this method, Debug implementation does not cause problems if a given fuzzy hash is broken.

source§

impl<const S1: usize, const S2: usize> From<&FuzzyHashData<S1, S2, true>> for FuzzyHashCompareTargetwhere BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

source§

fn from(value: &FuzzyHashData<S1, S2, true>) -> Self

Converts to this type from the input type.
source§

impl<const NORM: bool> From<FuzzyHashData<{BlockHash::FULL_SIZE}, {BlockHash::HALF_SIZE}, NORM>> for FuzzyHashData<{ BlockHash::FULL_SIZE }, { BlockHash::FULL_SIZE }, NORM>

source§

fn from( value: FuzzyHashData<{ BlockHash::FULL_SIZE }, { BlockHash::HALF_SIZE }, NORM> ) -> Self

Converts to this type from the input type.
source§

impl From<FuzzyHashData<{BlockHash::FULL_SIZE}, {BlockHash::HALF_SIZE}, true>> for FuzzyHashData<{ BlockHash::FULL_SIZE }, { BlockHash::FULL_SIZE }, false>

source§

fn from( value: FuzzyHashData<{ BlockHash::FULL_SIZE }, { BlockHash::HALF_SIZE }, true> ) -> Self

Converts to this type from the input type.
source§

impl<const S1: usize, const S2: usize, const NORM: bool> From<FuzzyHashData<S1, S2, NORM>> for Stringwhere BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

Available on crate feature alloc only.
source§

fn from(value: FuzzyHashData<S1, S2, NORM>) -> Self

Converts to this type from the input type.
source§

impl<const S1: usize, const S2: usize> From<FuzzyHashData<S1, S2, false>> for FuzzyHashData<S1, S2, { _ }>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

source§

fn from(value: FuzzyHashData<S1, S2, { _ }>) -> Self

Converts to this type from the input type.
source§

impl<const S1: usize, const S2: usize, const C1: usize, const C2: usize> From<FuzzyHashData<S1, S2, false>> for FuzzyHashDualData<S1, S2, C1, C2>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes, RleBlockSizeForBlockHash<S1, C1>: ConstrainedRleBlockSizeForBlockHash, RleBlockSizeForBlockHash<S2, C2>: ConstrainedRleBlockSizeForBlockHash,

source§

fn from(value: FuzzyHashData<S1, S2, false>) -> Self

Converts to this type from the input type.
source§

impl<const S1: usize, const S2: usize> From<FuzzyHashData<S1, S2, true>> for FuzzyHashCompareTargetwhere BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

source§

fn from(value: FuzzyHashData<S1, S2, true>) -> Self

Converts to this type from the input type.
source§

impl<const S1: usize, const S2: usize> From<FuzzyHashData<S1, S2, true>> for FuzzyHashData<S1, S2, { _ }>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

source§

fn from(value: FuzzyHashData<S1, S2, { _ }>) -> Self

Converts to this type from the input type.
source§

impl<const S1: usize, const S2: usize, const C1: usize, const C2: usize> From<FuzzyHashData<S1, S2, true>> for FuzzyHashDualData<S1, S2, C1, C2>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes, RleBlockSizeForBlockHash<S1, C1>: ConstrainedRleBlockSizeForBlockHash, RleBlockSizeForBlockHash<S2, C2>: ConstrainedRleBlockSizeForBlockHash,

source§

fn from(value: FuzzyHashData<S1, S2, true>) -> Self

Converts to this type from the input type.
source§

impl<const S1: usize, const S2: usize, const NORM: bool> FromStr for FuzzyHashData<S1, S2, NORM>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

§

type Err = ParseError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl<const S1: usize, const S2: usize, const NORM: bool> Hash for FuzzyHashData<S1, S2, NORM>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<const S1: usize, const S2: usize, const NORM: bool> Ord for FuzzyHashData<S1, S2, NORM>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl<const S1: usize, const S2: usize, const NORM: bool> PartialEq<FuzzyHashData<S1, S2, NORM>> for FuzzyHashData<S1, S2, NORM>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<const S1: usize, const S2: usize, const NORM: bool> PartialOrd<FuzzyHashData<S1, S2, NORM>> for FuzzyHashData<S1, S2, NORM>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<const NORM: bool> TryFrom<FuzzyHashData<{BlockHash::FULL_SIZE}, {BlockHash::FULL_SIZE}, NORM>> for FuzzyHashData<{ BlockHash::FULL_SIZE }, { BlockHash::HALF_SIZE }, NORM>

§

type Error = FuzzyHashOperationError

The type returned in the event of a conversion error.
source§

fn try_from( value: FuzzyHashData<{ BlockHash::FULL_SIZE }, { BlockHash::FULL_SIZE }, NORM> ) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<const S1: usize, const S2: usize, const NORM: bool> Copy for FuzzyHashData<S1, S2, NORM>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

source§

impl<const S1: usize, const S2: usize, const NORM: bool> Eq for FuzzyHashData<S1, S2, NORM>where BlockHashSize<S1>: ConstrainedBlockHashSize, BlockHashSize<S2>: ConstrainedBlockHashSize, BlockHashSizes<S1, S2>: ConstrainedBlockHashSizes,

Auto Trait Implementations§

§

impl<const S1: usize, const S2: usize, const NORM: bool> RefUnwindSafe for FuzzyHashData<S1, S2, NORM>

§

impl<const S1: usize, const S2: usize, const NORM: bool> Send for FuzzyHashData<S1, S2, NORM>

§

impl<const S1: usize, const S2: usize, const NORM: bool> Sync for FuzzyHashData<S1, S2, NORM>

§

impl<const S1: usize, const S2: usize, const NORM: bool> Unpin for FuzzyHashData<S1, S2, NORM>

§

impl<const S1: usize, const S2: usize, const NORM: bool> UnwindSafe for FuzzyHashData<S1, S2, NORM>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.