Trait penumbra_tct::internal::hash::GetHash

source ·
pub trait GetHash {
    // Required methods
    fn hash(&self) -> Hash;
    fn cached_hash(&self) -> Option<Hash>;

    // Provided method
    fn clear_cached_hash(&self) { ... }
}
Available on crate feature internal only.
Expand description

A type which can be transformed into a Hash, either by retrieving a cached hash, computing a hash for it, or some combination of both.

Required Methods§

source

fn hash(&self) -> Hash

Get the hash of this item.

§Correctness

This function must return the same hash for the same item. It is permissible to use internal mutability to cache hashes, but caching must ensure that the item cannot be mutated without recalculating the hash.

source

fn cached_hash(&self) -> Option<Hash>

Get the hash of this item, only if the hash is already cached and does not require recalculation.

§Correctness

It will not cause correctness issues to return a hash after recalculating it, but users of this function expect it to be reliably fast, so it may cause unexpected performance issues if this function performs any significant work.

Provided Methods§

source

fn clear_cached_hash(&self)

If there is a hash cached, clear the cache.

By default, this does nothing. Override this if there is a cache.

Implementations on Foreign Types§

source§

impl<T: GetHash> GetHash for &T

source§

fn hash(&self) -> Hash

source§

fn cached_hash(&self) -> Option<Hash>

source§

impl<T: GetHash> GetHash for &mut T

source§

fn hash(&self) -> Hash

source§

fn cached_hash(&self) -> Option<Hash>

Implementors§

source§

impl GetHash for penumbra_tct::structure::Node<'_>

source§

impl GetHash for penumbra_tct::internal::complete::Item

source§

impl GetHash for penumbra_tct::internal::frontier::Item

source§

impl<Child: Focus> GetHash for penumbra_tct::internal::frontier::Node<Child>

source§

impl<Child: Height + GetHash + Clone> GetHash for penumbra_tct::internal::complete::Node<Child>

source§

impl<Item: Focus + Clone> GetHash for penumbra_tct::internal::frontier::Tier<Item>
where Item::Complete: Clone,

source§

impl<Item: Focus + Clone> GetHash for penumbra_tct::internal::frontier::Top<Item>
where Item::Complete: Clone,

source§

impl<Item: GetHash + Height + Clone> GetHash for penumbra_tct::internal::complete::Tier<Item>

source§

impl<Item: GetHash + Height + Clone> GetHash for penumbra_tct::internal::complete::Top<Item>

source§

impl<Item: GetHash> GetHash for penumbra_tct::internal::complete::Leaf<Item>

source§

impl<Item: GetHash> GetHash for penumbra_tct::internal::frontier::Leaf<Item>

source§

impl<T: GetHash> GetHash for Insert<T>