BlockHashPositionArray

Struct BlockHashPositionArray 

Source
pub struct BlockHashPositionArray { /* private fields */ }
Expand description

A simple struct representing a position array of a block hash.

This type is not a part of the FuzzyHashCompareTarget struct but can be a good example to use internal efficient implementation.

It’s (currently) used internally on the FuzzyHashData::compare() method family (comparing two fuzzy hash objects) for the “shortcut path” (when the block sizes are different but near).

See also:

§Compatibility Notice

This type is going to be completely private on the next major release. If you need to experiment with internal hashing functions, just vendor the source code for your needs.

Implementations§

Source§

impl BlockHashPositionArray

Source

pub fn new() -> Self

Creates a new position array object with empty contents.

Source

pub fn clear(&mut self)

Clears the current representation of the block hash.

Source

pub fn init_from(&mut self, blockhash: &[u8])

Clear and initialize (encode) the object from a given slice.

§Usage Constraints

Trait Implementations§

Source§

impl BlockHashPositionArrayData for BlockHashPositionArray

Source§

fn representation(&self) -> &[u64; 64]

Returns the raw representation of the block hash position array.
Source§

fn len(&self) -> u8

Returns the length of the block hash.
Source§

fn is_empty(&self) -> bool

Returns whether the block hash is empty.
Source§

fn is_valid(&self) -> bool

Performs full validity checking of a position array object. Read more
Source§

fn is_valid_and_normalized(&self) -> bool

Performs full validity checking and the normalization test of a position array object. Read more
Source§

impl Debug for BlockHashPositionArray

Source§

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

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

impl Default for BlockHashPositionArray

Source§

fn default() -> Self

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

impl PartialEq for BlockHashPositionArray

Source§

fn eq(&self, other: &BlockHashPositionArray) -> 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 Eq for BlockHashPositionArray

Source§

impl StructuralPartialEq for BlockHashPositionArray

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> BlockHashPositionArrayImpl for T
where T: BlockHashPositionArrayImplInternal,

Source§

fn is_equiv(&self, other: &[u8]) -> bool

Compare whether two block hashes are equivalent. Read more
Source§

fn has_common_substring(&self, other: &[u8]) -> bool

Checks whether two given strings have common substrings with a length of block_hash::MIN_LCS_FOR_COMPARISON. Read more
Source§

fn edit_distance(&self, other: &[u8]) -> u32

Computes the edit distance between two given strings. Read more
Source§

fn score_strings_raw(&self, other: &[u8]) -> u32

Compare two block hashes and computes the similarity score without capping. Read more
Source§

fn score_strings(&self, other: &[u8], log_block_size: u8) -> u32

Compare two block hashes and computes the similarity score. Read more
Source§

impl<T> BlockHashPositionArrayImplUnchecked for T
where T: BlockHashPositionArrayImplInternal,

Source§

unsafe fn is_equiv_unchecked(&self, other: &[u8]) -> bool

Available on crate feature unchecked only.
Compare whether two block hashes are equivalent. Read more
Source§

unsafe fn has_common_substring_unchecked(&self, other: &[u8]) -> bool

Available on crate feature unchecked only.
Checks whether two given strings have common substrings with a length of block_hash::MIN_LCS_FOR_COMPARISON. Read more
Source§

unsafe fn edit_distance_unchecked(&self, other: &[u8]) -> u32

Available on crate feature unchecked only.
Computes the edit distance between two given strings. Read more
Source§

unsafe fn score_strings_raw_unchecked(&self, other: &[u8]) -> u32

Available on crate feature unchecked only.
Compare two block hashes and computes the similarity score without capping. Read more
Source§

unsafe fn score_strings_unchecked( &self, other: &[u8], log_block_size: u8, ) -> u32

Available on crate feature unchecked only.
Compare two block hashes and computes the similarity score. 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> 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, 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.