penumbra_tct::internal::hash

Trait 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>