Struct AHasher

struct AHasher { ... }

A Hasher for hashing an arbitrary stream of bytes.

Instances of AHasher represent state that is updated while hashing data.

Each method updates the internal state based on the new data provided. Once all of the data has been provided, the resulting hash can be obtained by calling finish()

[Clone] is also provided in case you wish to calculate hashes for two different items that start with the same data.

Implementations

impl Clone for AHasher

fn clone(self: &Self) -> AHasher

impl Debug for AHasher

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

impl Default for AHasher

fn default() -> AHasher

Constructs a new [AHasher] with fixed keys. If std is enabled these will be generated upon first invocation. Otherwise if the compile-time-rngfeature is enabled these will be generated at compile time. If neither of these features are available, hardcoded constants will be used.

Because the values are fixed, different hashers will all hash elements the same way. This could make hash values predictable, if DOS attacks are a concern. If this behaviour is not required, it may be preferable to use [RandomState] instead.

Examples

use ahash::AHasher;
use std::hash::Hasher;

let mut hasher_1 = AHasher::default();
let mut hasher_2 = AHasher::default();

hasher_1.write_u32(1234);
hasher_2.write_u32(1234);

assert_eq!(hasher_1.finish(), hasher_2.finish());

impl Freeze for AHasher

impl Hasher for AHasher

fn write_u8(self: &mut Self, i: u8)
fn write_u16(self: &mut Self, i: u16)
fn write_u32(self: &mut Self, i: u32)
fn write_u64(self: &mut Self, i: u64)
fn write_u128(self: &mut Self, i: u128)
fn write_usize(self: &mut Self, i: usize)
fn write(self: &mut Self, input: &[u8])
fn finish(self: &Self) -> u64

impl RefUnwindSafe for AHasher

impl Send for AHasher

impl Sync for AHasher

impl Unpin for AHasher

impl UnsafeUnpin for AHasher

impl UnwindSafe for AHasher

impl<T> Any for AHasher

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for AHasher

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for AHasher

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

impl<T> CloneToUninit for AHasher

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

impl<T> From for AHasher

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for AHasher

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for AHasher

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for AHasher

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for AHasher

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>