[][src]Struct blockhash::Blockhash256

pub struct Blockhash256(_);

A 256-bit hash digest.

Implementations

impl Blockhash256[src]

pub fn distance(&self, other: &Self) -> u32[src]

Returns the Hamming distance between two hashes.

Examples

use blockhash::Blockhash256;

let a = Blockhash256::from([
    0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
    0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
    0xff, 0xef, 0xdf, 0xcf, 0xbf, 0xaf, 0x9f, 0x8f,
    0x7f, 0x6f, 0x5f, 0x4f, 0x3f, 0x2f, 0x1f, 0x0f,
]);
let b = Blockhash256::from([
    0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
    0xf8, 0xf9, 0x3a, 0xfb, 0xfc, 0xfd, 0x0e, 0xff,
    0xff, 0xff, 0xdf, 0xcf, 0xbf, 0xaf, 0x9f, 0x8f,
    0x7f, 0x6f, 0x5f, 0x4f, 0x3f, 0x2f, 0x1f, 0x0f,
]);

assert_eq!(a.distance(&b), 11);

Trait Implementations

impl Clone for Blockhash256[src]

impl Copy for Blockhash256[src]

impl Debug for Blockhash256[src]

impl Display for Blockhash256[src]

impl Eq for Blockhash256[src]

impl From<[u8; 32]> for Blockhash256[src]

impl From<Blockhash256> for [u8; 32][src]

impl FromStr for Blockhash256[src]

type Err = BlockhashParseError

The associated error which can be returned from parsing.

impl Hash for Blockhash256[src]

impl Ord for Blockhash256[src]

impl PartialEq<Blockhash256> for Blockhash256[src]

impl PartialOrd<Blockhash256> for Blockhash256[src]

impl StructuralEq for Blockhash256[src]

impl StructuralPartialEq for Blockhash256[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SetParameter for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.