Enum BlockSizeRelation

Source
pub enum BlockSizeRelation {
    NearLt,
    NearEq,
    NearGt,
    Far,
}
Expand description

A type to represent relation between two block sizes.

Because the core comparison function can only compare two block hashes with the same effective 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:

  1. Equals (NearEq)
    bs_a == bs_b
  2. Less than (NearLt)
    bs_a < bs_b && bs_a * 2 == bs_b
  3. Greater than (NearGt)
    bs_a > bs_b && bs_a == bs_b * 2

See also: “Relations with Block Size” section of FuzzyHashData

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).

A value of this type can be retrieved by using block_size::compare_sizes() or FuzzyHashData::compare_block_sizes().

§Compatibility Note

Since the version 0.3, the representation of this enum is no longer specified as specific representation of this enum is not important.

Variants§

§

NearLt

Near and less than (i.e. x < x * 2).

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

Near and equals (i.e. x == x).

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

Near and greater than (i.e. x * 2 > x).

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.

§

Far

Far (e.g. x and x * 4).

Two block sizes are far and a block hash comparison cannot be performed.

Implementations§

Source§

impl BlockSizeRelation

Source

pub fn is_near(&self) -> bool

Checks whether a given value denotes one of the three near cases.

Trait Implementations§

Source§

impl Clone for BlockSizeRelation

Source§

fn clone(&self) -> BlockSizeRelation

Returns a duplicate 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 Debug for BlockSizeRelation

Source§

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

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

impl PartialEq for BlockSizeRelation

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for BlockSizeRelation

Source§

impl Eq for BlockSizeRelation

Source§

impl StructuralPartialEq for BlockSizeRelation

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.