Debian Codegraph @

/

debian rust-twox-hash 2.1.2-2debian librust-twox-hash-dev debian librust-twox-hash+alloc-dev debian librust-twox-hash+default-dev debian librust-twox-hash+random-dev debian librust-twox-hash+serialize-dev debian librust-twox-hash+std-dev debian librust-twox-hash+xxhash32-dev debian librust-twox-hash+xxhash3-128-dev debian librust-twox-hash+xxhash3-64-dev debian librust-twox-hash+xxhash64-dev debian librust-twox-hash-2-dev debian librust-twox-hash-2+alloc-dev debian librust-twox-hash-2+default-dev debian librust-twox-hash-2+random-dev debian librust-twox-hash-2+serialize-dev debian librust-twox-hash-2+std-dev debian librust-twox-hash-2+xxhash32-dev debian librust-twox-hash-2+xxhash3-128-dev debian librust-twox-hash-2+xxhash3-64-dev
22 more… debian librust-twox-hash-2+xxhash64-dev debian librust-twox-hash-2.1-dev debian librust-twox-hash-2.1+alloc-dev debian librust-twox-hash-2.1+default-dev debian librust-twox-hash-2.1+random-dev debian librust-twox-hash-2.1+serialize-dev debian librust-twox-hash-2.1+std-dev debian librust-twox-hash-2.1+xxhash32-dev debian librust-twox-hash-2.1+xxhash3-128-dev debian librust-twox-hash-2.1+xxhash3-64-dev debian librust-twox-hash-2.1+xxhash64-dev debian librust-twox-hash-2.1.2-dev debian librust-twox-hash-2.1.2+alloc-dev debian librust-twox-hash-2.1.2+default-dev debian librust-twox-hash-2.1.2+random-dev debian librust-twox-hash-2.1.2+serialize-dev debian librust-twox-hash-2.1.2+std-dev debian librust-twox-hash-2.1.2+xxhash32-dev debian librust-twox-hash-2.1.2+xxhash3-128-dev debian librust-twox-hash-2.1.2+xxhash3-64-dev debian librust-twox-hash-2.1.2+xxhash64-dev cargo twox-hash 2.1.2
debianjsonmakefilemarkdownrustrustrust-c-abishelltomlyaml 32 files · 787 symbols
View dependency graph

Depends on

  • dh-cargo (dh-sequence-cargo)
  • rust-rand-0.8 (librust-rand-0.8+std-dev, librust-rand-0.8+std-rng-dev)
  • cargo, debhelper-compat, librust-serde-1+derive-dev, libstd-rust-dev, rustc
README (full)

A Rust implementation of the xxHash algorithm.

Crates.io Documentation Build Status

Examples

These examples use XxHash64 but the same ideas can be used for XxHash32, XxHash3_64, or XxHash3_128.

Hashing arbitrary data

When all the data is available at once

# #[cfg(feature = "xxhash64")]
# {
use twox_hash::XxHash64;

let seed = 1234;
let hash = XxHash64::oneshot(seed, b"some bytes");
assert_eq!(0xeab5_5659_a496_d78b, hash);
# }

When the data is streaming

# #[cfg(feature = "xxhash64")]
# {
use std::hash::Hasher as _;
use twox_hash::XxHash64;

let seed = 1234;
let mut hasher = XxHash64::with_seed(seed);
hasher.write(b"some");
hasher.write(b" ");
hasher.write(b"bytes");
let hash = hasher.finish();
assert_eq!(0xeab5_5659_a496_d78b, hash);
# }

In a HashMap

With a default seed

# #[cfg(feature = "xxhash64")]
# {
use std::{collections::HashMap, hash::BuildHasherDefault};
use twox_hash::XxHash64;

let mut hash = HashMap::<_, _, BuildHasherDefault<XxHash64>>::default();
hash.insert(42, "the answer");
assert_eq!(hash.get(&42), Some(&"the answer"));
# }

With a random seed

# #[cfg(all(feature = "xxhash64", feature = "random"))]
# {
use std::collections::HashMap;
use twox_hash::xxhash64;

let mut hash = HashMap::<_, _, xxhash64::RandomState>::default();
hash.insert(42, "the answer");
assert_eq!(hash.get(&42), Some(&"the answer"));
# }

With a fixed seed

# #[cfg(feature = "xxhash64")]
# {
use std::collections::HashMap;
use twox_hash::xxhash64;

let mut hash = HashMap::with_hasher(xxhash64::State::with_seed(0xdead_cafe));
hash.insert(42, "the answer");
assert_eq!(hash.get(&42), Some(&"the answer"));
# }

Feature Flags

namedescription
xxhash32Include the XxHash32 algorithm
xxhash64Include the XxHash64 algorithm
xxhash3_64Include the XxHash3_64 algorithm
xxhash3_128Include the XxHash3_128 algorithm
randomCreate random instances of the hashers
serializeSerialize and deserialize hasher state with Serde
stdUse the Rust standard library. Enable this if you want SIMD support in XxHash3_64 or XxHash3_128
allocUse the Rust allocator library. Enable this if you want to create XxHash3_64 or XxHash3_128 with dynamic secrets

Benchmarks

See benchmarks in the comparison README.

Contributing

  1. Fork it (https://github.com/shepmaster/twox-hash/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Add a failing test.
  4. Add code to pass the test.
  5. Commit your changes (git commit -am 'Add some feature')
  6. Ensure tests pass.
  7. Push to the branch (git push origin my-new-feature)
  8. Create a new Pull Request
dir .github/
dir debian/
dir src/
file .cargo_vcs_info.json
file .gitignore
file .gitmodules
file CHANGELOG.md
file Cargo.lock
file Cargo.toml
file Cargo.toml.orig
file LICENSE.txt
file README.md
file clippy.toml