pub struct Fingerprinter { /* private fields */ }Expand description
Streaming hasher for building a Fingerprint.
Each absorb_* writes a per-type discriminator byte, the caller’s content
tag, and a length before the data, so absorb_f64(b"x", 0.5) cannot
collide with absorb_bytes(b"x", <the 8 little-endian bytes of 0.5>), nor
with absorb_u64(b"x", 0.5f64.to_bits()) — heterogeneous fields sharing a
tag can never alias.
Implementations§
Source§impl Fingerprinter
impl Fingerprinter
pub fn new() -> Self
Sourcepub fn absorb_tag(&mut self, tag: &[u8])
pub fn absorb_tag(&mut self, tag: &[u8])
Absorb a tag with no payload. Useful for structural separators.
pub fn absorb_bytes(&mut self, tag: &[u8], data: &[u8])
pub fn absorb_str(&mut self, tag: &[u8], s: &str)
pub fn absorb_u64(&mut self, tag: &[u8], v: u64)
pub fn absorb_f64(&mut self, tag: &[u8], v: f64)
pub fn absorb_f64_slice(&mut self, tag: &[u8], xs: &[f64])
pub fn absorb_f64_2d( &mut self, tag: &[u8], rows: usize, cols: usize, xs: &[f64], )
pub fn finalize(self) -> Fingerprint
pub fn write_bytes(&mut self, data: &[u8])
pub fn write_u8(&mut self, value: u8)
pub fn write_bool(&mut self, value: bool)
pub fn write_u64(&mut self, value: u64)
pub fn write_usize(&mut self, value: usize)
pub fn write_f64(&mut self, value: f64)
pub fn write_str(&mut self, value: &str)
Sourcepub fn write_f64_slice(&mut self, values: &[f64])
pub fn write_f64_slice(&mut self, values: &[f64])
Absorb a length-prefixed f64 slice using the per-element
Fingerprinter::write_f64 contract (so -0.0 is normalized to
+0.0). Canonical home for the byte-identical len-then-each-f64
hashing that previously lived as module-local hash_f64_slice /
hash_vector copies in solver/latent_cache. Uses a bulk byte path
only when it can emit exactly the same bytes as the element-wise
normalizing protocol.
Sourcepub fn write_f64_array1(&mut self, values: &Array1<f64>)
pub fn write_f64_array1(&mut self, values: &Array1<f64>)
Absorb a 1D f64 array as len followed by every element via
Fingerprinter::write_f64. Canonical home for the byte-identical
hash_vector copy that previously lived in solver/latent_cache.
Sourcepub fn write_f64_array2(&mut self, values: &Array2<f64>)
pub fn write_f64_array2(&mut self, values: &Array2<f64>)
Absorb a 2D f64 array as (nrows, ncols) followed by every element in
iteration order, each via Fingerprinter::write_f64. Canonical home
for the byte-identical heuristic that previously lived as module-local
write_array2_fingerprint (solver/arrow_schur) and hash_matrix
(solver/latent_cache) copies.
Sourcepub fn finish_u64(self) -> u64
pub fn finish_u64(self) -> u64
Finalize and return the first 8 bytes of the SHA-256 digest as a
little-endian u64. Used by callers that need a compact in-process
identifier (manifold mode fingerprints, registry fingerprints, …)
rather than the full 32-byte Fingerprint.
Sourcepub fn finish_hex(self) -> String
pub fn finish_hex(self) -> String
Finalize and return a zero-padded 16-character hex representation
of Fingerprinter::finish_u64, suitable for embedding directly
in cache-key strings.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Fingerprinter
impl RefUnwindSafe for Fingerprinter
impl Send for Fingerprinter
impl Sync for Fingerprinter
impl Unpin for Fingerprinter
impl UnsafeUnpin for Fingerprinter
impl UnwindSafe for Fingerprinter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more