Skip to main content

Xxh3_64

Struct Xxh3_64 

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

XXH3 64-bit hash.

A fast non-cryptographic hash using the XXH3 algorithm. Supports an optional u64 seed and an optional custom 192-byte secret.

Incremental hashing (update) produces exactly the same value as one-shot hashing (checksum, or the xxh3_64 free function), for any input length and any split of the input across update calls. No input can make it panic.

When the std feature is enabled (the default), the long-input path uses AVX2 / AVX-512 (x86) or NEON (aarch64) kernels selected at runtime; with no_std, the kernels are selected at compile time from the enabled target features.

§Security

XXH3 is not a cryptographic hash: it must not be used to authenticate messages, derive keys, or store passwords, and a seed or a custom secret is not a security boundary. It is also not collision-resistant against deliberate attacks; do not use it to defend a hash table against attacker-chosen keys (hash flooding).

§Example

use xxhash::{Xxh3_64, Checksum};

let hash = Xxh3_64::checksum(b"hello world");

Implementations§

Source§

impl Xxh3_64

Source

pub const fn with_seed(seed: u64) -> Self

Create a new XXH3-64 hasher with the given seed.

A zero seed is equivalent to the default, unseeded hasher.

Source

pub const fn with_secret(secret: [u8; 192]) -> Self

Create a new XXH3-64 hasher with a custom 192-byte secret (seed = 0).

Source

pub const fn with_seed_and_secret(seed: u64, secret: [u8; 192]) -> Self

Create a new XXH3-64 hasher with a custom seed and secret.

This matches the reference XXH3_64bits_withSecretandSeed() contract: the seed is used for inputs of up to 240 bytes (with the default secret), while the custom secret is used — and the seed is ignored — for longer inputs.

Trait Implementations§

Source§

impl Checksum for Xxh3_64

Source§

type Output = u64

The type of the resulting checksum value.
Source§

fn new() -> Self

Create a new checksum instance with default settings (seed = 0, default secret for XXH3 variants).
Source§

fn checksum(data: &[u8]) -> u64

Compute the checksum of data in a single call.
Source§

fn update(&mut self, data: &[u8])

Feed additional data into the checksum.
Source§

fn sum(self) -> u64

Finalize and return the computed checksum value.
Source§

impl Clone for Xxh3_64

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Xxh3_64

Source§

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

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

impl Default for Xxh3_64

Source§

fn default() -> Self

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

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.