Struct HashX

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

Pre-built hash program that can be rapidly computed with different inputs

The program and initial state representation are not specified in this public interface, but std::fmt::Debug can describe program internals.

Implementations§

Source§

impl HashX

Source

pub const FULL_SIZE: usize = 32usize

The maximum available output size for Self::hash_to_bytes()

Source

pub fn new(seed: &[u8]) -> Result<Self, Error>

Generate a new hash function with the supplied seed.

Source

pub fn runtime(&self) -> Runtime

Check which actual program runtime is in effect.

By default we try to generate code at runtime to accelerate the hash function, but we fall back to an interpreter if this fails. The compiler can be disabled entirely using RuntimeOption::InterpretOnly and HashXBuilder.

Source

pub fn hash_to_u64(&self, input: u64) -> u64

Calculate the first 64-bit word of the hash, without converting to bytes.

Source

pub fn hash_to_bytes(&self, input: u64) -> [u8; 32]

Calculate the hash function at its full output width, returning a fixed size byte array.

Trait Implementations§

Source§

impl Debug for HashX

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for HashX

§

impl RefUnwindSafe for HashX

§

impl Send for HashX

§

impl Sync for HashX

§

impl Unpin for HashX

§

impl UnwindSafe for HashX

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.