Skip to main content

Hashable

Trait Hashable 

Source
pub trait Hashable {
    // Required method
    fn calc_hash(&self) -> Hash256;
}
Expand description

The Hashable trait indicates, that we can generate a Hash256 from this type.

Note: In general, we can calculate a Hash256 from anything that implements AsRef<[u8]>, but in our scenario not all items have a hash that is identical to their binary representation. This trait is here to fix this issue, as implementers can define a complete custom method of how the object-hash should be calculated.

Required Methods§

Source

fn calc_hash(&self) -> Hash256

Calculates and returns the hash of the datatype

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T: Hashed> Hashable for T