pub struct InputHasher { /* private fields */ }Expand description
Hashes a model’s input for Provenance::input_hash, so an audit can
confirm that two results came from the same data.
Each field is written as a one-byte type tag, a little-endian u64
length, then the payload, so neither field boundaries nor types can be
confused: str("ab").str("c") differs from str("a").str("bc"), and
u64(1) from i64(1). Floats are hashed by their bits, with -0.0
written as 0.0 and every NaN as one canonical NaN, so numerically
equal inputs hash equal.
use prospicio_prob::provenance::InputHasher;
let a = InputHasher::new().str("origin").f64s(&[100.0, 150.0]).finish();
let b = InputHasher::new().str("origin").f64s(&[100.0, 150.0]).finish();
assert_eq!(a, b);
assert!(a.starts_with("blake3:"));
assert_ne!(a, InputHasher::new().str("origin").f64s(&[100.0, 151.0]).finish());Implementations§
Source§impl InputHasher
impl InputHasher
Trait Implementations§
Source§impl Clone for InputHasher
impl Clone for InputHasher
Source§fn clone(&self) -> InputHasher
fn clone(&self) -> InputHasher
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InputHasher
impl Debug for InputHasher
Auto Trait Implementations§
impl Freeze for InputHasher
impl RefUnwindSafe for InputHasher
impl Send for InputHasher
impl Sync for InputHasher
impl Unpin for InputHasher
impl UnsafeUnpin for InputHasher
impl UnwindSafe for InputHasher
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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 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> ⓘ
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