Enum ssdeep::BlockSizeRelation
source · #[repr(u32)]
pub enum BlockSizeRelation {
Far,
NearLt,
NearEq,
NearGt,
}
Expand description
A type to represent relation between two block sizes.
Because the core comparison method can only compare two block hashes with the same block size, we cannot compare two fuzzy hashes if their block sizes are not near enough.
There are three cases where we can perform actual block hash comparison:
- Equals (
NearEq
)
bs_a == bs_b
- Less than (
NearLt
)
bs_a < bs_b && bs_a * 2 == bs_b
- Greater than (
NearGt
)
bs_a > bs_b && bs_a == bs_b * 2
This type represents those near cases (three variants) and the case which
two fuzzy hashes cannot perform a block hash comparison, the far case
(the Far
variant).
In this crate, it can efficiently handle such relations by using the base-2 logarithms form of the block size (no multiplication required).
Variants§
Far
Two block sizes are far and a block hash comparison cannot be performed.
NearLt
Two block sizes are near and the block hash 2 (one with a larger block size) of the left side (of comparison) can be compared with the block hash 1 (one with a smaller block size) of the right side.
NearEq
Two block sizes are not just near but the same. We compare both block hashes with the other and take the maximum value for the output.
NearGt
Two block sizes are near and the block hash 1 (one with a smaller block size) of the left side (of comparison) can be compared with the block hash 2 (one with a larger block size) of the right side.
Implementations§
Trait Implementations§
source§impl Clone for BlockSizeRelation
impl Clone for BlockSizeRelation
source§fn clone(&self) -> BlockSizeRelation
fn clone(&self) -> BlockSizeRelation
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for BlockSizeRelation
impl Debug for BlockSizeRelation
source§impl PartialEq<BlockSizeRelation> for BlockSizeRelation
impl PartialEq<BlockSizeRelation> for BlockSizeRelation
source§fn eq(&self, other: &BlockSizeRelation) -> bool
fn eq(&self, other: &BlockSizeRelation) -> bool
self
and other
values to be equal, and is used
by ==
.