Author: Peter Green <plugwash@debian.org>
Bug-Debian: https://bugs.debian.org/1119017
Last-Update: 2026-01-24
Description: Upgrade to twox-hash version 2

--- sourmash.orig/src/core/Cargo.toml
+++ sourmash/src/core/Cargo.toml
@@ -58,7 +58,7 @@
 statrs = "0.18.0"
 streaming-stats = "0.2.3"
 thiserror = "2.0"
-twox-hash = "1.6.0"
+twox-hash = "2"
 typed-builder = ">= 0.21"
 vec-collections = "0.4.3"
 
--- sourmash.orig/src/core/src/encodings.rs
+++ sourmash/src/core/src/encodings.rs
@@ -470,7 +470,7 @@
     }
 
     fn compute_color(idxs: &IdxTracker) -> Color {
-        let s = BuildHasherDefault::<twox_hash::Xxh3Hash128>::default();
+        let s = BuildHasherDefault::<crate::Xxh3Hash128>::default();
         s.hash_one(&idxs.0)
     }
 
--- sourmash.orig/src/core/src/index/revindex/disk_revindex.rs
+++ sourmash/src/core/src/index/revindex/disk_revindex.rs
@@ -36,7 +36,7 @@
 const PROCESSED: &str = "processed";
 
 fn compute_color(idxs: &Datasets) -> Color {
-    let s = BuildHasherDefault::<twox_hash::Xxh3Hash128>::default();
+    let s = BuildHasherDefault::<crate::Xxh3Hash128>::default();
     s.hash_one(idxs)
 }
 
--- sourmash.orig/src/core/src/lib.rs
+++ sourmash/src/core/src/lib.rs
@@ -40,6 +40,24 @@
 use cfg_if::cfg_if;
 use murmurhash3::murmurhash3_x64_128;
 
+//compatibility struct to support twox_hash version 2
+#[derive(Default)]
+struct Xxh3Hash128(twox_hash::XxHash3_128);
+
+impl std::hash::Hasher for Xxh3Hash128 {
+    #[inline(always)]
+    fn finish(&self) -> u64 {
+        // this truncates the 128-bit value to 64-bits,
+        // which reflects what xxhash 1.x did.
+        self.0.finish_128() as u64
+    }
+
+    #[inline(always)]
+    fn write(&mut self, bytes: &[u8]) {
+        self.0.write(bytes)
+    }
+}
+
 cfg_if! {
     if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
         // Explicitly keeping emscripten and wasi out of this
