pub trait Hashable {
// Required method
fn update_context(&self, context: &mut Sha3);
}
Expand description
The type of values stored in a MerkleTree
must implement
this trait, in order for them to be able to be fed
to a Ring Context
when computing the hash of a leaf.
A default instance for types that already implements
AsRef<[u8]>
is provided.
§Example
Here is an example of how to implement Hashable
for a type
that does not (or cannot) implement AsRef<[u8]>
:
ⓘ
impl Hashable for PublicKey {
fn update_context(&self, context: &mut Context) {
let bytes: Vec<u8> = self.to_bytes();
context.update(&bytes);
}
}
Required Methods§
Sourcefn update_context(&self, context: &mut Sha3)
fn update_context(&self, context: &mut Sha3)
Update the given context
with self
.
See ring::digest::Context::update
for more information.