[][src]Trait indy_utils::hash::Hashable

pub trait Hashable {
    pub fn update_context<D: Digest>(
        &self,
        context: &mut D
    ) -> Result<(), ValidationError>; }

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]>:

This example is not tested
impl Hashable for PublicKey {
    fn update_context(&self, context: &mut Hasher) -> Result<(), CommonError> {
        let bytes: Vec<u8> = self.to_bytes();
        Ok(context.update(&bytes)?)
    }
}

Required methods

pub fn update_context<D: Digest>(
    &self,
    context: &mut D
) -> Result<(), ValidationError>
[src]

Update the given context with self.

See openssl::hash::Hasher::update for more information.

Loading content...

Implementors

impl<T: AsRef<[u8]>> Hashable for T[src]

Loading content...