Skip to main content

DataHasher

Struct DataHasher 

Source
pub struct DataHasher { /* private fields */ }
Expand description

Streaming Data-Code generator.

Incrementally processes data with content-defined chunking (CDC) and MinHash to produce an ISCC Data-Code identical to gen_data_code_v0 for the same byte stream. Uses a persistent internal buffer to avoid per-call heap allocations.

Implementations§

Source§

impl DataHasher

Source

pub fn new() -> Self

Create a new DataHasher.

Source

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

Push data into the hasher.

Appends data to the internal buffer (which starts with the retained tail from the previous call), runs CDC, hashes all complete chunks, and shifts the last chunk (tail) to the front of the buffer for the next call. The buffer is reused across calls to avoid allocations.

Source

pub fn finalize(self, bits: u32) -> IsccResult<DataCodeResult>

Consume the hasher and produce a Data-Code result.

Equivalent to calling gen_data_code_v0 with the concatenation of all data passed to update.

Trait Implementations§

Source§

impl Default for DataHasher

Source§

fn default() -> Self

Create a new DataHasher (delegates to new()).

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, 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.