pub struct HashBuilder { /* private fields */ }Expand description
Builder for incremental hashing
Useful when hashing data that arrives in chunks or from multiple sources.
§Example
use atlas_common::hash::{HashBuilder, HashAlgorithm};
let mut builder = HashBuilder::new(HashAlgorithm::Sha256);
builder.update(b"part1");
builder.update(b"part2");
let hash = builder.finalize();Implementations§
Source§impl HashBuilder
impl HashBuilder
Sourcepub fn new(algorithm: HashAlgorithm) -> Self
pub fn new(algorithm: HashAlgorithm) -> Self
Create a new hash builder with the specified algorithm
Sourcepub fn update(&mut self, data: &[u8])
pub fn update(&mut self, data: &[u8])
Update the hash with more data
Can be called multiple times to add data incrementally.
Sourcepub fn finalize(self) -> String
pub fn finalize(self) -> String
Finalize and get the hash as a hex string
Consumes the builder.
Sourcepub fn algorithm(&self) -> HashAlgorithm
pub fn algorithm(&self) -> HashAlgorithm
Get the algorithm being used
Auto Trait Implementations§
impl Freeze for HashBuilder
impl RefUnwindSafe for HashBuilder
impl Send for HashBuilder
impl Sync for HashBuilder
impl Unpin for HashBuilder
impl UnsafeUnpin for HashBuilder
impl UnwindSafe for HashBuilder
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
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