Struct kaspa_muhash::MuHash
source · pub struct MuHash { /* private fields */ }
Expand description
MuHash is a type used to create a Multiplicative Hash which is a rolling(homomorphic) hash that you can add and remove elements from and receive the same resulting hash as-if you never hashed them. Because of that the order of adding and removing elements doesn’t matter.
Implementations§
source§impl MuHash
impl MuHash
sourcepub fn new() -> Self
pub fn new() -> Self
return an empty initialized set. when finalized it should be equal to a finalized set with all elements removed.
pub fn add_element(&mut self, data: &[u8])
pub fn remove_element(&mut self, data: &[u8])
pub fn add_element_builder(&mut self) -> MuHashElementBuilder<'_>
pub fn remove_element_builder(&mut self) -> MuHashElementBuilder<'_>
pub fn combine(&mut self, other: &Self)
pub fn finalize(&mut self) -> Hash
pub fn serialize(&mut self) -> [u8; 384]
pub fn deserialize(data: [u8; 384]) -> Result<Self, OverflowError>
Trait Implementations§
source§impl<'de> Deserialize<'de> for MuHash
impl<'de> Deserialize<'de> for MuHash
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl RefUnwindSafe for MuHash
impl Send for MuHash
impl Sync for MuHash
impl Unpin for MuHash
impl UnwindSafe for MuHash
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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