### Using Xxh3_64Builder with HashMap Source: https://docs.rs/hashcrew/latest/hashcrew/xxhash/struct.Xxh3_64Builder.html Example of initializing a HashMap with an Xxh3_64Builder using a specific seed. ```rust use std::collections::HashMap; use hashcrew::xxhash::Xxh3_64Builder; let builder = Xxh3_64Builder::with_seed(42); let mut counts = HashMap::with_hasher(builder); counts.insert("apple", 3); assert_eq!(counts.get("apple"), Some(&3)); ``` -------------------------------- ### Complete and incremental hashing with Xxh64 Source: https://docs.rs/hashcrew/latest/index.html Demonstrates how to hash a complete byte slice using the xxh64 free function and how to incrementally hash data using the Xxh64 stateful API. The example shows that both methods produce the same digest. ```APIDOC ## Complete and incremental hashing ### Description Hash a complete byte slice with a free function, or feed the same bytes to a reusable state. ### Code Example ```rust use hashcrew::xxhash::Xxh64; use hashcrew::xxhash::xxh64; let expected = xxh64(b"hashcrew", 42); let mut state = Xxh64::with_seed(42); state.update(b"hash"); state.update(b"crew"); assert_eq!(state.digest(), expected); ``` ``` -------------------------------- ### Hash with cityhash64_with_seed Source: https://docs.rs/hashcrew/latest/hashcrew/cityhash/index.html Example of using the cityhash64_with_seed function to hash a byte slice with a 64-bit seed. ```rust use hashcrew::cityhash::cityhash64_with_seed; let digest = cityhash64_with_seed(b"hashcrew", 42); assert_ne!(digest, 0); ``` -------------------------------- ### Md5::new Source: https://docs.rs/hashcrew/latest/hashcrew/md5/struct.Md5.html?search= Creates a new MD5 state. This is a constructor function that initializes the hash state. ```APIDOC ## Md5::new ### Description Creates a new MD5 state. ### Method Constructor ### Signature pub const fn new() -> Self ### Parameters None ### Returns - **Self** - A new Md5 instance. ### Example ```rust let mut md5 = Md5::new(); ``` ``` -------------------------------- ### CRC Kernel Reduction and PCLMUL Source: https://docs.rs/hashcrew/latest/src/hashcrew/crc/kernel/x86.rs.html Example of folding values and performing PCLMUL reduction for the CASTAGNOLI polynomial. ```rust value = fold(value, factors, _mm512_extracti32x4_epi32(a, 1)); value = fold(value, factors, _mm512_extracti32x4_epi32(a, 2)); value = fold(value, factors, _mm512_extracti32x4_epi32(a, 3)); let state = reduce::(value); pclmul::(state, &input[blocks * 192..]) } } ``` -------------------------------- ### Shift start parameter calculation Source: https://docs.rs/hashcrew/latest/src/hashcrew/crc/kernel/mod.rs.html Calculates the initial shift parameters for CRC kernels, handling potential overflows for large input lengths. ```rust #[cfg(all( any(target_arch = "aarch64", target_arch = "x86_64"), target_endian = "little", not(miri) ))] #[inline] fn shift_start(bytes: usize) -> (u64, u64) { // Shift kernels start with n = 8 * bytes - 33, for bytes >= 8. If that // overflows u64, take initial exponent-reduction steps before multiplying: // floor((m * bytes - 33) / 2) - 16 = (m / 2) * bytes - 33. // Each discarded low bit is one. Ordinary lengths stay in u64 arithmetic. let bytes = bytes as u64; let mut multiplier = 8; let mut stack = !1_u64; while bytes > u64::MAX / multiplier { stack = (stack << 1) | 1; multiplier >>= 1; } (bytes * multiplier - 33, stack) } ``` -------------------------------- ### hashcrew API Overview Source: https://docs.rs/hashcrew/latest/hashcrew/all.html?search= A structured overview of the hashcrew crate's public API, listing all structs, enums, functions, and constants available for direct use. ```APIDOC ## hashcrew 0.3.0 API Reference ### Description This document provides a structured overview of the hashcrew crate's public API. It lists all structs, enums, functions, and constants that users can directly call or use in their Rust projects. ### Structs - **crc::Crc32Iscsi** - CRC-32 (ISCSI) hash struct - **crc::Crc32IsoHdlc** - CRC-32 (ISO-HDLC) hash struct - **fnv::Fnv1a32** - FNV-1a 32-bit hash struct - **fnv::Fnv1a32Builder** - Builder for Fnv1a32 - **fnv::Fnv1a64** - FNV-1a 64-bit hash struct - **fnv::Fnv1a64Builder** - Builder for Fnv1a64 - **md5::Md5** - MD5 hash struct - **murmur::Murmur3X64_128** - MurmurHash3 x64 128-bit hash struct - **murmur::Murmur3X86_128** - MurmurHash3 x86 128-bit hash struct - **murmur::Murmur3X86_32** - MurmurHash3 x86 32-bit hash struct - **murmur::Murmur3X86_32Builder** - Builder for Murmur3X86_32 - **xxhash::Xxh32** - XXH32 hash struct - **xxhash::Xxh32Builder** - Builder for Xxh32 - **xxhash::Xxh3SecretTooShort** - Error struct for XXH3 secret too short - **xxhash::Xxh3_128** - XXH3 128-bit hash struct - **xxhash::Xxh3_64** - XXH3 64-bit hash struct - **xxhash::Xxh3_64Builder** - Builder for Xxh3_64 - **xxhash::Xxh3_64SecretBuilder** - Builder for Xxh3_64 with secret - **xxhash::Xxh64** - XXH64 hash struct - **xxhash::Xxh64Builder** - Builder for Xxh64 ### Enums - **xxhash::kernel::Backend** - Backend selection enum for XXHash ### Functions - **cityhash::cityhash128** - Compute 128-bit CityHash - **cityhash::cityhash128_to_64** - Compute 64-bit CityHash from 128-bit - **cityhash::cityhash128_with_seed** - Compute 128-bit CityHash with seed - **cityhash::cityhash32** - Compute 32-bit CityHash - **cityhash::cityhash64** - Compute 64-bit CityHash - **cityhash::cityhash64_with_seed** - Compute 64-bit CityHash with seed - **cityhash::cityhash64_with_seeds** - Compute 64-bit CityHash with two seeds - **crc::crc32_iscsi** - Compute CRC-32 (ISCSI) - **crc::crc32_iscsi_combine** - Combine two CRC-32 (ISCSI) values - **crc::crc32_iso_hdlc** - Compute CRC-32 (ISO-HDLC) - **crc::crc32_iso_hdlc_combine** - Combine two CRC-32 (ISO-HDLC) values - **fnv::fnv1a_32** - Compute FNV-1a 32-bit hash - **fnv::fnv1a_32_with_offset_basis** - Compute FNV-1a 32-bit hash with offset basis - **fnv::fnv1a_64** - Compute FNV-1a 64-bit hash - **fnv::fnv1a_64_with_offset_basis** - Compute FNV-1a 64-bit hash with offset basis - **md5::md5** - Compute MD5 hash - **murmur::murmur3_x64_128** - Compute MurmurHash3 x64 128-bit - **murmur::murmur3_x86_128** - Compute MurmurHash3 x86 128-bit - **murmur::murmur3_x86_32** - Compute MurmurHash3 x86 32-bit - **xxhash::kernel::selected_backend** - Get selected XXHash backend - **xxhash::xxh32** - Compute XXH32 hash - **xxhash::xxh3_128** - Compute XXH3 128-bit hash - **xxhash::xxh3_128_with_secret** - Compute XXH3 128-bit hash with secret - **xxhash::xxh3_128_with_seed** - Compute XXH3 128-bit hash with seed - **xxhash::xxh3_128_with_seed_and_secret** - Compute XXH3 128-bit hash with seed and secret - **xxhash::xxh3_64** - Compute XXH3 64-bit hash - **xxhash::xxh3_64_with_secret** - Compute XXH3 64-bit hash with secret - **xxhash::xxh3_64_with_seed** - Compute XXH3 64-bit hash with seed - **xxhash::xxh3_64_with_seed_and_secret** - Compute XXH3 64-bit hash with seed and secret - **xxhash::xxh64** - Compute XXH64 hash ### Constants - **fnv::FNV1A_32_OFFSET_BASIS** - Offset basis for FNV-1a 32-bit - **fnv::FNV1A_32_PRIME** - Prime for FNV-1a 32-bit - **fnv::FNV1A_64_OFFSET_BASIS** - Offset basis for FNV-1a 64-bit - **fnv::FNV1A_64_PRIME** - Prime for FNV-1a 64-bit - **xxhash::DEFAULT_SECRET** - Default secret for XXH3 - **xxhash::DEFAULT_SECRET_SIZE** - Default secret size for XXH3 - **xxhash::SECRET_SIZE_MIN** - Minimum secret size for XXH3 ``` -------------------------------- ### hashcrew API Overview Source: https://docs.rs/hashcrew/latest/hashcrew/all.html?search=std%3A%3Avec A structured overview of the hashcrew crate's public API, including all structs, enums, functions, and constants available to users. ```APIDOC # hashcrew 0.3.0 API Reference ## Overview The hashcrew crate provides a collection of hashing algorithms. This document lists all public items available for direct use. ## Structs - `crc::Crc32Iscsi` - CRC32 (ISCSI variant) streaming hasher. - `crc::Crc32IsoHdlc` - CRC32 (ISO HDLC variant) streaming hasher. - `fnv::Fnv1a32` - FNV-1a 32-bit streaming hasher. - `fnv::Fnv1a32Builder` - Builder for FNV-1a 32-bit hasher. - `fnv::Fnv1a64` - FNV-1a 64-bit streaming hasher. - `fnv::Fnv1a64Builder` - Builder for FNV-1a 64-bit hasher. - `md5::Md5` - MD5 streaming hasher. - `murmur::Murmur3X64_128` - MurmurHash3 x64 128-bit streaming hasher. - `murmur::Murmur3X86_128` - MurmurHash3 x86 128-bit streaming hasher. - `murmur::Murmur3X86_32` - MurmurHash3 x86 32-bit streaming hasher. - `murmur::Murmur3X86_32Builder` - Builder for MurmurHash3 x86 32-bit hasher. - `xxhash::Xxh32` - XXH32 streaming hasher. - `xxhash::Xxh32Builder` - Builder for XXH32 hasher. - `xxhash::Xxh3SecretTooShort` - Error type for XXH3 secret too short. - `xxhash::Xxh3_128` - XXH3 128-bit streaming hasher. - `xxhash::Xxh3_64` - XXH3 64-bit streaming hasher. - `xxhash::Xxh3_64Builder` - Builder for XXH3 64-bit hasher. - `xxhash::Xxh3_64SecretBuilder` - Builder for XXH3 64-bit hasher with secret. - `xxhash::Xxh64` - XXH64 streaming hasher. - `xxhash::Xxh64Builder` - Builder for XXH64 hasher. ## Enums - `xxhash::kernel::Backend` - Enum representing the backend used by XXH3. ## Functions ### CityHash - `cityhash::cityhash128` - Computes a 128-bit CityHash. - `cityhash::cityhash128_to_64` - Computes a 64-bit hash from a 128-bit CityHash. - `cityhash::cityhash128_with_seed` - Computes a 128-bit CityHash with a seed. - `cityhash::cityhash32` - Computes a 32-bit CityHash. - `cityhash::cityhash64` - Computes a 64-bit CityHash. - `cityhash::cityhash64_with_seed` - Computes a 64-bit CityHash with a seed. - `cityhash::cityhash64_with_seeds` - Computes a 64-bit CityHash with two seeds. ### CRC - `crc::crc32_iscsi` - Computes CRC32 (ISCSI variant). - `crc::crc32_iscsi_combine` - Combines two CRC32 (ISCSI) values. - `crc::crc32_iso_hdlc` - Computes CRC32 (ISO HDLC variant). - `crc::crc32_iso_hdlc_combine` - Combines two CRC32 (ISO HDLC) values. ### FNV - `fnv::fnv1a_32` - Computes FNV-1a 32-bit hash. - `fnv::fnv1a_32_with_offset_basis` - Computes FNV-1a 32-bit hash with custom offset basis. - `fnv::fnv1a_64` - Computes FNV-1a 64-bit hash. - `fnv::fnv1a_64_with_offset_basis` - Computes FNV-1a 64-bit hash with custom offset basis. ### MD5 - `md5::md5` - Computes MD5 hash. ### MurmurHash - `murmur::murmur3_x64_128` - Computes MurmurHash3 x64 128-bit hash. - `murmur::murmur3_x86_128` - Computes MurmurHash3 x86 128-bit hash. - `murmur::murmur3_x86_32` - Computes MurmurHash3 x86 32-bit hash. ### XXHash - `xxhash::kernel::selected_backend` - Returns the selected backend for XXH3. - `xxhash::xxh32` - Computes XXH32 hash. - `xxhash::xxh3_128` - Computes XXH3 128-bit hash. - `xxhash::xxh3_128_with_secret` - Computes XXH3 128-bit hash with secret. - `xxhash::xxh3_128_with_seed` - Computes XXH3 128-bit hash with seed. - `xxhash::xxh3_128_with_seed_and_secret` - Computes XXH3 128-bit hash with seed and secret. - `xxhash::xxh3_64` - Computes XXH3 64-bit hash. - `xxhash::xxh3_64_with_secret` - Computes XXH3 64-bit hash with secret. - `xxhash::xxh3_64_with_seed` - Computes XXH3 64-bit hash with seed. - `xxhash::xxh3_64_with_seed_and_secret` - Computes XXH3 64-bit hash with seed and secret. - `xxhash::xxh64` - Computes XXH64 hash. ## Constants - `fnv::FNV1A_32_OFFSET_BASIS` - Offset basis for FNV-1a 32-bit. - `fnv::FNV1A_32_PRIME` - Prime for FNV-1a 32-bit. - `fnv::FNV1A_64_OFFSET_BASIS` - Offset basis for FNV-1a 64-bit. - `fnv::FNV1A_64_PRIME` - Prime for FNV-1a 64-bit. - `xxhash::DEFAULT_SECRET` - Default secret for XXH3. - `xxhash::DEFAULT_SECRET_SIZE` - Default secret size for XXH3. - `xxhash::SECRET_SIZE_MIN` - Minimum secret size for XXH3. ``` -------------------------------- ### Format MD5 digest as 32-character hexadecimal checksum Source: https://docs.rs/hashcrew/latest/hashcrew/md5/index.html?search=u32+-%3E+bool Converts the 16-byte MD5 digest to a 32-character lowercase hexadecimal string, preserving standard MD5 order and leading zeroes. The example asserts the checksum for input 'a' is '0cc175b9c0f1b6a831c399e269772661'. ```rust use hashcrew::md5::md5; let digest = md5(b"a"); let checksum = format!("{:032x}", u128::from_be_bytes(digest)); assert_eq!(checksum, "0cc175b9c0f1b6a831c399e269772661"); ``` -------------------------------- ### Xxh3_64Builder Source: https://docs.rs/hashcrew/latest/src/hashcrew/xxhash/mod.rs.html?search=u32+-%3E+bool Builder for configuring and creating Xxh3_64 instances. ```APIDOC ## Xxh3_64Builder ### Description Builder for configuring and creating Xxh3_64 instances. ### Methods - `new() -> Self` - Creates a new builder with default settings. - `build(&self) -> Xxh3_64` - Builds an Xxh3_64 instance. ### Example ```rust use hashcrew::xxhash::Xxh3_64Builder; let builder = Xxh3_64Builder::new(); let state = builder.build(); ``` ``` -------------------------------- ### Xxh3_64Builder Source: https://docs.rs/hashcrew/latest/hashcrew/xxhash/index.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Deterministic BuildHasher for Xxh3_64. ```APIDOC ## Xxh3_64Builder ### Description Deterministic `BuildHasher` for `Xxh3_64`. ### Methods - `new() -> Self` - Creates a new builder with default seed. - `build_hasher(&self) -> Xxh3_64` - Creates a new hasher. ``` -------------------------------- ### Xxh32Builder Source: https://docs.rs/hashcrew/latest/src/hashcrew/xxhash/mod.rs.html?search=u32+-%3E+bool Builder for configuring and creating Xxh32 instances. ```APIDOC ## Xxh32Builder ### Description Builder for configuring and creating Xxh32 instances. ### Methods - `new() -> Self` - Creates a new builder with default settings. - `build(&self) -> Xxh32` - Builds an Xxh32 instance. ### Example ```rust use hashcrew::xxhash::Xxh32Builder; let builder = Xxh32Builder::new(); let state = builder.build(); ``` ``` -------------------------------- ### Using Murmur3X64_128 streaming state and murmur3_x64_128 one-shot function Source: https://docs.rs/hashcrew/latest/hashcrew/murmur/index.html?search=u32+-%3E+bool Shows how to create a Murmur3X64_128 state with a seed, update it with data, and compare its digest to the one-shot murmur3_x64_128 function. Requires the murmur feature. ```rust use hashcrew::murmur::Murmur3X64_128; use hashcrew::murmur::murmur3_x64_128; let mut state = Murmur3X64_128::with_seed(42); state.update(b"hash"); state.update(b"crew"); assert_eq!(state.digest(), murmur3_x64_128(b"hashcrew", 42)); ``` -------------------------------- ### Xxh3_64Builder::default Source: https://docs.rs/hashcrew/latest/src/hashcrew/xxhash/xxh3.rs.html?search= Creates a default Xxh3_64Builder with seed 0. ```APIDOC ## Xxh3_64Builder::default ### Description Creates a default Xxh3_64Builder with seed 0. ### Method Trait implementation (Default) ### Signature fn default() -> Self ### Returns - **Self** - A new Xxh3_64Builder with seed 0. ### Example ```rust use hashcrew::xxhash::Xxh3_64Builder; let builder = Xxh3_64Builder::default(); ``` ``` -------------------------------- ### Fnv1a64Builder Source: https://docs.rs/hashcrew/latest/hashcrew/fnv/index.html?search=u32+-%3E+bool Deterministic BuildHasher for Fnv1a64. ```APIDOC ## Fnv1a64Builder ### Description Deterministic `BuildHasher` for `Fnv1a64`. Use for trusted-input hash collections. ### Methods - **new()** - Creates a new builder with the standard offset basis. ### Example ```rust use hashcrew::fnv::Fnv1a64Builder; let builder = Fnv1a64Builder::new(); ``` ``` -------------------------------- ### Fnv1a64::new Source: https://docs.rs/hashcrew/latest/hashcrew/fnv/struct.Fnv1a64.html Creates a new Fnv1a64 state using the standard offset basis. ```APIDOC ## Fnv1a64::new ### Description Creates a new Fnv1a64 state using the standard offset basis. ### Method new ### Signature pub const fn new() -> Self ### Parameters None ### Returns Self - A new Fnv1a64 instance with the standard offset basis. ``` -------------------------------- ### xxh64 and Xxh64 Source: https://docs.rs/hashcrew Demonstrates complete hashing with the xxh64 free function and incremental hashing with the Xxh64 stateful type, both using a seed of 42. ```APIDOC ## xxh64 and Xxh64 ### Description Hash a complete byte slice with the free function xxh64, or feed the same bytes to a reusable Xxh64 state for incremental hashing. ### Usage Example ```rust use hashcrew::xxhash::Xxh64; use hashcrew::xxhash::xxh64; let expected = xxh64(b"hashcrew", 42); let mut state = Xxh64::with_seed(42); state.update(b"hash"); state.update(b"crew"); assert_eq!(state.digest(), expected); ``` ``` -------------------------------- ### Xxh64::new Source: https://docs.rs/hashcrew/latest/hashcrew/xxhash/struct.Xxh64.html Creates an unseeded XXH64 state. ```APIDOC ## Xxh64::new ### Description Creates an unseeded XXH64 state. ### Method new ### Signature pub const fn new() -> Self ### Parameters None ### Returns Self - A new Xxh64 instance with no seed. ``` -------------------------------- ### Xxh64::new Source: https://docs.rs/hashcrew/latest/hashcrew/xxhash/struct.Xxh64.html?search=u32+-%3E+bool Creates an unseeded XXH64 state. ```APIDOC ## Xxh64::new ### Description Creates an unseeded XXH64 state. ### Signature pub const fn new() -> Self ### Parameters None ### Returns Self - A new Xxh64 instance with no seed. ``` -------------------------------- ### Xxh64::new Source: https://docs.rs/hashcrew/latest/hashcrew/xxhash/struct.Xxh64.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Creates an unseeded XXH64 state. ```APIDOC ## Xxh64::new ### Description Creates an unseeded XXH64 state. ### Method new ### Signature pub const fn new() -> Self ### Parameters None ### Returns Self - A new Xxh64 instance. ``` -------------------------------- ### Xxh32Builder Source: https://docs.rs/hashcrew/latest/hashcrew/xxhash/index.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Deterministic BuildHasher for Xxh32. ```APIDOC ## Xxh32Builder ### Description Deterministic `BuildHasher` for `Xxh32`. ### Methods - `new() -> Self` - Creates a new builder with default seed. - `build_hasher(&self) -> Xxh32` - Creates a new hasher. ``` -------------------------------- ### Backend::is_available Source: https://docs.rs/hashcrew/latest/hashcrew/xxhash/kernel/enum.Backend.html Returns whether this backend can execute safely on the current CPU. This method is used to check if a particular backend is supported on the current hardware. ```APIDOC ## Backend::is_available ### Description Returns whether this backend can execute safely on the current CPU. ### Method pub fn is_available(self) -> bool ### Parameters - self (Backend) - Required - The backend instance to check. ### Returns - bool - True if the backend can execute safely on the current CPU, false otherwise. ### Example ```rust let backend = Backend::Avx2; if backend.is_available() { // Use AVX2 backend } ``` ``` -------------------------------- ### Xxh64Builder Source: https://docs.rs/hashcrew/latest/src/hashcrew/xxhash/mod.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Builder for creating Xxh64 instances with custom seeds. ```APIDOC ## Xxh64Builder ### Description Builder for creating Xxh64 instances with custom seeds. ### Methods #### new `pub fn new() -> Self` Creates a new builder with default seed. #### with_seed `pub fn with_seed(self, seed: u64) -> Self` Sets the seed for the hash. #### build `pub fn build(self) -> Xxh64` Builds the Xxh64 instance. ### Example ```rust use hashcrew::xxhash::Xxh64Builder; let builder = Xxh64Builder::new().with_seed(42); let state = builder.build(); ``` ``` -------------------------------- ### Backend::is_available Source: https://docs.rs/hashcrew/latest/hashcrew/xxhash/kernel/enum.Backend.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Returns whether this backend can execute safely on the current CPU. This method is used to determine if a specific backend variant is supported on the host hardware. ```APIDOC ## Backend::is_available ### Description Returns whether this backend can execute safely on the current CPU. ### Method pub fn is_available(self) -> bool ### Parameters - self (Backend) - Required - The backend variant to check. ### Returns - bool - True if the backend can execute safely on the current CPU, false otherwise. ### Example ```rust let backend = Backend::Avx2; if backend.is_available() { // Use AVX2 backend } ``` ``` -------------------------------- ### Xxh3_64::new Source: https://docs.rs/hashcrew/latest/hashcrew/xxhash/struct.Xxh3_64.html Creates an unseeded XXH3-64 state. ```APIDOC ## Xxh3_64::new ### Description Creates an unseeded XXH3-64 state. ### Method new ### Signature pub const fn new() -> Self ### Parameters None ### Returns Self - A new unseeded XXH3-64 state. ``` -------------------------------- ### Perform incremental and one-shot XXH3-64 hashing Source: https://docs.rs/hashcrew/latest/hashcrew/xxhash/index.html?search= Demonstrates how to use the Xxh3_64 state for incremental updates and compare the result with a one-shot xxh3_64 hash. ```rust use hashcrew::xxhash::Xxh3_64; use hashcrew::xxhash::xxh3_64; let mut state = Xxh3_64::new(); state.update(b"hash"); state.update(b"crew"); assert_eq!(state.digest(), xxh3_64(b"hashcrew")); ``` -------------------------------- ### Xxh3_64::with_seed Source: https://docs.rs/hashcrew/latest/hashcrew/xxhash/struct.Xxh3_64.html Creates an XXH3-64 state with a seed. ```APIDOC ## Xxh3_64::with_seed ### Description Creates an XXH3-64 state with a seed. ### Method with_seed ### Signature pub const fn with_seed(seed: u64) -> Self ### Parameters - **seed** (u64) - Required - The seed value for the hash state. ### Returns Self - A new XXH3-64 state initialized with the given seed. ``` -------------------------------- ### Xxh32Builder Source: https://docs.rs/hashcrew/latest/src/hashcrew/xxhash/mod.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Builder for creating Xxh32 instances with custom seeds. ```APIDOC ## Xxh32Builder ### Description Builder for creating Xxh32 instances with custom seeds. ### Methods #### new `pub fn new() -> Self` Creates a new builder with default seed. #### with_seed `pub fn with_seed(self, seed: u32) -> Self` Sets the seed for the hash. #### build `pub fn build(self) -> Xxh32` Builds the Xxh32 instance. ### Example ```rust use hashcrew::xxhash::Xxh32Builder; let builder = Xxh32Builder::new().with_seed(42); let state = builder.build(); ``` ``` -------------------------------- ### XXH32 Implementation Source Source: https://docs.rs/hashcrew/latest/src/hashcrew/xxhash/xxh32.rs.html?search= The complete implementation of the XXH32 algorithm, including prime constants, accumulator logic, and the public xxh32 function. ```rust 1// Copyright 2026 FastLabs Developers 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15// Portions of this implementation are derived from xxHash's xxhash.h. 16// Copyright (C) 2012-2023 Yann Collet 17// Hashcrew's modifications are Apache-2.0; the derived portions remain BSD-2-Clause. 18// See LICENSE for the full upstream terms. 19// Reference source (xxHash 0.8.3): 20// https://github.com/Cyan4973/xxHash/blob/e626a72bc2321cd320e953a0ccf1584cad60f363/xxhash.h 21 22//! XXH32 one-shot and streaming APIs. 23 24use core::hash::BuildHasher; 25use core::hash::Hasher; 26 27use crate::read_u32; 28 29const PRIME1: u32 = 0x9e37_79b1; 30const PRIME2: u32 = 0x85eb_ca77; 31const PRIME3: u32 = 0xc2b2_ae3d; 32const PRIME4: u32 = 0x27d4_eb2f; 33const PRIME5: u32 = 0x1656_67b1; 34 35// Store each adjacent pair in reverse logical order. This keeps the input 36// multiplication outside the accumulator dependency chain in AArch64 codegen. 37#[derive(Clone, Debug)] 38struct Accumulators([u32; 4]); 39 40impl Accumulators { 41 const fn new(seed: u32) -> Self { 42 Self([ 43 seed.wrapping_add(PRIME2), 44 seed.wrapping_add(PRIME1).wrapping_add(PRIME2), 45 seed.wrapping_sub(PRIME1), 46 seed, 47 ]) 48 } 49 50 #[inline] 51 fn consume(&mut self, input: [u32; 4]) { 52 let [acc1, acc0, acc3, acc2] = &mut self.0; 53 let [product0, product1, product2, product3] = 54 input.map(|lane| u32::from_le(lane).wrapping_mul(PRIME2)); 55 *acc0 = round_product(*acc0, product0); 56 *acc1 = round_product(*acc1, product1); 57 *acc2 = round_product(*acc2, product2); 58 *acc3 = round_product(*acc3, product3); 59 } 60 61 const fn digest(&self) -> u32 { 62 let [acc1, acc0, acc3, acc2] = self.0; 63 acc0.rotate_left(1) 64 .wrapping_add(acc1.rotate_left(7)) 65 .wrapping_add(acc2.rotate_left(12)) 66 .wrapping_add(acc3.rotate_left(18)) 67 } 68} 69 70#[inline] 71const fn round(acc: u32, lane: u32) -> u32 { 72 round_product(acc, lane.wrapping_mul(PRIME2)) 73} 74 75#[inline] 76const fn round_product(acc: u32, product: u32) -> u32 { 77 let acc = acc.wrapping_add(product); 78 let acc = acc.rotate_left(13); 79 acc.wrapping_mul(PRIME1) 80} 81 82#[inline(always)] 83fn avalanche(mut hash: u32) -> u32 { 84 hash ^= hash >> 15; 85 hash = hash.wrapping_mul(PRIME2); 86 hash ^= hash >> 13; 87 hash = hash.wrapping_mul(PRIME3); 88 hash ^ (hash >> 16) 89} 90 91#[inline(always)] 92fn consume_tail(mut hash: u32, tail: &[u8]) -> u32 { 93 let mut offset = 0; 94 while offset + 4 <= tail.len() { 95 hash = hash.wrapping_add(read_u32(tail, offset).wrapping_mul(PRIME3)); 96 hash = hash.rotate_left(17).wrapping_mul(PRIME4); 97 offset += 4; 98 } 99 for &byte in &tail[offset..] { 100 hash = hash.wrapping_add(u32::from(byte).wrapping_mul(PRIME5)); 101 hash = hash.rotate_left(11).wrapping_mul(PRIME1); 102 } 103 avalanche(hash) 104} 105 106/// Hashes `input` with XXH32 and `seed`. 107#[must_use] 108#[inline] 109pub fn xxh32(input: &[u8], seed: u32) -> u32 { 110 let mut offset = 0; 111 let mut lanes = [ 112 seed.wrapping_add(PRIME1).wrapping_add(PRIME2), 113 seed.wrapping_add(PRIME2), 114 seed, 115 seed.wrapping_sub(PRIME1), 116 ]; 117 118 while offset + 16 <= input.len() { 119 lanes[0] = round(lanes[0], read_u32(input, offset)); 120 lanes[1] = round(lanes[1], read_u32(input, offset + 4)); 121 lanes[2] = round(lanes[2], read_u32(input, offset + 8)); 122 lanes[3] = round(lanes[3], read_u32(input, offset + 12)); 123 offset += 16; 124 } 125 126 let mut hash = if input.len() >= 16 { 127 lanes[0] 128 .rotate_left(1) 129 .wrapping_add(lanes[1].rotate_left(7)) 130 .wrapping_add(lanes[2].rotate_left(12)) 131 .wrapping_add(lanes[3].rotate_left(18)) 132 } else { 133 seed.wrapping_add(PRIME5) 134 }; 135 hash = hash.wrapping_add(input.len() as u32); 136 consume_tail(hash, &input[offset..]) 137} 138 139/// Incremental XXH32 state. 140#[derive(Clone, Debug)] 141pub struct Xxh32 { 142 seed: u32, 143 lanes: Accumulators, 144 buffer: [u8; 16], ``` -------------------------------- ### xxh64 one-shot and Xxh64 streaming Source: https://docs.rs/hashcrew/latest/hashcrew/index.html Demonstrates hashing a complete byte slice with the xxh64 free function and feeding bytes incrementally to an Xxh64 state, producing the same digest. ```APIDOC ## xxh64 one-shot and Xxh64 streaming ### Description Hash a complete byte slice with the xxh64 free function, or feed the same bytes to a reusable Xxh64 state. ### Usage ```rust use hashcrew::xxhash::Xxh64; use hashcrew::xxhash::xxh64; let expected = xxh64(b"hashcrew", 42); let mut state = Xxh64::with_seed(42); state.update(b"hash"); state.update(b"crew"); assert_eq!(state.digest(), expected); ``` ### Functions - `xxh64(data: &[u8], seed: u64) -> u64` - One-shot hash of a byte slice with a seed. - `Xxh64::with_seed(seed: u64) -> Xxh64` - Creates a new streaming state with the given seed. - `Xxh64::update(&mut self, data: &[u8])` - Feeds bytes into the streaming state. - `Xxh64::digest(&self) -> u64` - Returns the final hash value. ``` -------------------------------- ### Fnv1a32::new Source: https://docs.rs/hashcrew/latest/hashcrew/fnv/struct.Fnv1a32.html Creates a new Fnv1a32 state using the standard offset basis. ```APIDOC ## Fnv1a32::new ### Description Creates a new Fnv1a32 state using the standard offset basis. ### Method pub const fn new() -> Self ### Parameters None ### Returns Self - A new Fnv1a32 instance. ``` -------------------------------- ### Xxh32::new Source: https://docs.rs/hashcrew/latest/hashcrew/xxhash/struct.Xxh32.html Creates an unseeded XXH32 state. ```APIDOC ## Xxh32::new ### Description Creates an unseeded XXH32 state. ### Method new ### Signature pub const fn new() -> Self ### Parameters None ### Returns Self - A new Xxh32 instance with no seed. ``` -------------------------------- ### Xxh32::new Source: https://docs.rs/hashcrew/latest/hashcrew/xxhash/struct.Xxh32.html?search= Creates an unseeded XXH32 state. ```APIDOC ## Xxh32::new ### Description Creates an unseeded XXH32 state. ### Method new ### Signature pub const fn new() -> Self ### Parameters None ### Returns Self - A new Xxh32 instance with no seed. ``` -------------------------------- ### Fnv1a32Builder Source: https://docs.rs/hashcrew/latest/hashcrew/fnv/index.html?search=u32+-%3E+bool Deterministic BuildHasher for Fnv1a32. ```APIDOC ## Fnv1a32Builder ### Description Deterministic `BuildHasher` for `Fnv1a32`. Use for trusted-input hash collections. ### Methods - **new()** - Creates a new builder with the standard offset basis. ### Example ```rust use hashcrew::fnv::Fnv1a32Builder; let builder = Fnv1a32Builder::new(); ``` ``` -------------------------------- ### Xxh64Builder Source: https://docs.rs/hashcrew/latest/src/hashcrew/xxhash/mod.rs.html Builder for creating Xxh64 streaming states with optional seed configuration. ```APIDOC ## Xxh64Builder ### Description Builder for constructing Xxh64 streaming states, allowing seed configuration. ### Methods - **new()** - Creates a new builder with default settings. - **with_seed(seed: u64) -> Xxh64Builder** - Sets the seed for the hash. - **build(&self) -> Xxh64** - Builds the Xxh64 state. ### Example ```rust use hashcrew::xxhash::Xxh64Builder; let builder = Xxh64Builder::new().with_seed(42); let state = builder.build(); ``` ``` -------------------------------- ### Backend::is_available Source: https://docs.rs/hashcrew/latest/hashcrew/xxhash/kernel/enum.Backend.html?search=std%3A%3Avec Returns whether this backend can execute safely on the current CPU. ```APIDOC ## Backend::is_available ### Description Returns whether this backend can execute safely on the current CPU. ### Method is_available ### Signature pub fn is_available(self) -> bool ### Parameters - self (Backend) - The backend instance. ### Return Value - bool - True if the backend can execute safely on the current CPU, false otherwise. ### Example ```rust let backend = Backend::Avx2; if backend.is_available() { // Use AVX2 backend } ``` ``` -------------------------------- ### Backend::is_available Source: https://docs.rs/hashcrew/latest/hashcrew/xxhash/kernel/enum.Backend.html?search=u32+-%3E+bool Returns whether this backend can execute safely on the current CPU. ```APIDOC ## Backend::is_available ### Description Returns whether this backend can execute safely on the current CPU. ### Method pub fn is_available(self) -> bool ### Parameters - **self** (Backend) - Required - The backend instance to check. ### Returns - **bool** - True if the backend can execute safely on the current CPU, false otherwise. ### Example ```rust let backend = Backend::Avx2; let available = backend.is_available(); ``` ``` -------------------------------- ### Crc32IsoHdlc::new Source: https://docs.rs/hashcrew/latest/hashcrew/crc/struct.Crc32IsoHdlc.html Creates an empty CRC-32/ISO-HDLC state. ```APIDOC ## Crc32IsoHdlc::new ### Description Creates an empty CRC-32/ISO-HDLC state. ### Method new ### Signature pub const fn new() -> Self ### Parameters None ### Returns - **Self** - A new Crc32IsoHdlc instance with an empty state. ``` -------------------------------- ### Crc32IsoHdlc::new Source: https://docs.rs/hashcrew/latest/hashcrew/crc/struct.Crc32IsoHdlc.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Creates an empty CRC-32/ISO-HDLC state. ```APIDOC ## Crc32IsoHdlc::new ### Description Creates an empty CRC-32/ISO-HDLC state. ### Method `pub const fn new() -> Self` ### Parameters None. ### Returns - `Self` - A new `Crc32IsoHdlc` instance with an empty state. ``` -------------------------------- ### Xxh3_64Builder Source: https://docs.rs/hashcrew/latest/src/hashcrew/xxhash/mod.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Builder for creating Xxh3_64 instances with custom seeds. ```APIDOC ## Xxh3_64Builder ### Description Builder for creating Xxh3_64 instances with custom seeds. ### Methods #### new `pub fn new() -> Self` Creates a new builder with default seed. #### with_seed `pub fn with_seed(self, seed: u64) -> Self` Sets the seed for the hash. #### build `pub fn build(self) -> Xxh3_64` Builds the Xxh3_64 instance. ### Example ```rust use hashcrew::xxhash::Xxh3_64Builder; let builder = Xxh3_64Builder::new().with_seed(42); let state = builder.build(); ``` ``` -------------------------------- ### Md5::new Source: https://docs.rs/hashcrew/latest/hashcrew/md5/struct.Md5.html Creates a new MD5 state. This is a const function, so it can be used in constant contexts. ```APIDOC ## Md5::new ### Description Creates a new MD5 state. ### Method new ### Signature pub const fn new() -> Self ### Parameters None ### Returns - Self - A new Md5 instance. ``` -------------------------------- ### Xxh64Builder Implementation Source: https://docs.rs/hashcrew/latest/src/hashcrew/xxhash/xxh64.rs.html A deterministic BuildHasher for Xxh64, suitable for trusted inputs. ```rust /// Deterministic [`BuildHasher`] for [`Xxh64`]. /// /// This builder is intended for trusted inputs. It does not randomize its seed /// and is not resistant to deliberate hash-flooding attacks. #[derive(Clone, Copy, Debug, Default)] pub struct Xxh64Builder { seed: u64, } impl Xxh64Builder { /// Creates a builder using `seed`. #[must_use] pub const fn with_seed(seed: u64) -> Self { Self { seed } } } impl BuildHasher for Xxh64Builder { type Hasher = Xxh64; #[inline] fn build_hasher(&self) -> Self::Hasher { Xxh64::with_seed(self.seed) } } ``` -------------------------------- ### Murmur3X86_32Builder Source: https://docs.rs/hashcrew/latest/hashcrew/murmur/index.html?search=u32+-%3E+bool Deterministic BuildHasher for Murmur3X86_32. ```APIDOC ## Struct Murmur3X86_32Builder ### Description Deterministic `BuildHasher` for `Murmur3X86_32`. ### Methods - **new() -> Self** - Creates a new builder with a default seed. - **with_seed(seed: u32) -> Self** - Creates a new builder with the given seed. ### Example ```rust use hashcrew::murmur::Murmur3X86_32Builder; let builder = Murmur3X86_32Builder::with_seed(42); ``` ``` -------------------------------- ### Xxh3_64Builder Source: https://docs.rs/hashcrew/latest/src/hashcrew/xxhash/mod.rs.html?search= Builder for creating Xxh3_64 hasher instances. ```APIDOC ## Xxh3_64Builder ### Description Builder type for constructing Xxh3_64 hasher instances with custom parameters. ### Methods - **new()** - Creates a new builder with default parameters. - **build() -> Xxh3_64** - Constructs an Xxh3_64 hasher. ### Example ```rust use hashcrew::xxhash::Xxh3_64Builder; let builder = Xxh3_64Builder::new(); let hasher = builder.build(); ``` ```