Skip to main content

Fingerprinter

Struct Fingerprinter 

Source
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

Source

pub fn new() -> Self

Source

pub fn absorb_tag(&mut self, tag: &[u8])

Absorb a tag with no payload. Useful for structural separators.

Source

pub fn absorb_bytes(&mut self, tag: &[u8], data: &[u8])

Source

pub fn absorb_str(&mut self, tag: &[u8], s: &str)

Source

pub fn absorb_u64(&mut self, tag: &[u8], v: u64)

Source

pub fn absorb_f64(&mut self, tag: &[u8], v: f64)

Source

pub fn absorb_f64_slice(&mut self, tag: &[u8], xs: &[f64])

Source

pub fn absorb_f64_2d( &mut self, tag: &[u8], rows: usize, cols: usize, xs: &[f64], )

Source

pub fn finalize(self) -> Fingerprint

Source

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

Source

pub fn write_u8(&mut self, value: u8)

Source

pub fn write_bool(&mut self, value: bool)

Source

pub fn write_u64(&mut self, value: u64)

Source

pub fn write_usize(&mut self, value: usize)

Source

pub fn write_f64(&mut self, value: f64)

Source

pub fn write_str(&mut self, value: &str)

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl Default for Fingerprinter

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.