Skip to main content

ContentHash

Trait ContentHash 

Source
pub trait ContentHash {
    // Required method
    fn hash(&self, state: &mut impl Update);
}
Expand description

Portable, stable hashing suitable for identifying values

Variable-length sequences should hash a 64-bit little-endian representation of their length, then their elements in order. Unordered containers should order their elements according to their Ord implementation. Enums should hash a 32-bit little-endian encoding of the ordinal number of the enum variant, then the variant’s fields in lexical order.

Structs can implement ContentHash by using #[derive(ContentHash)].

Required Methods§

Source

fn hash(&self, state: &mut impl Update)

Update the hasher state with this object’s content

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl ContentHash for ()

Source§

fn hash(&self, _: &mut impl Update)

Source§

impl ContentHash for String

Source§

fn hash(&self, state: &mut impl Update)

Source§

impl ContentHash for bool

Source§

fn hash(&self, state: &mut impl Update)

Source§

impl ContentHash for i32

Source§

fn hash(&self, state: &mut impl Update)

Source§

impl ContentHash for i64

Source§

fn hash(&self, state: &mut impl Update)

Source§

impl ContentHash for str

Source§

fn hash(&self, state: &mut impl Update)

Source§

impl ContentHash for u8

Source§

fn hash(&self, state: &mut impl Update)

Source§

impl ContentHash for u32

Source§

fn hash(&self, state: &mut impl Update)

Source§

impl ContentHash for u64

Source§

fn hash(&self, state: &mut impl Update)

Source§

impl<K, V> ContentHash for BTreeMap<K, V>
where K: ContentHash, V: ContentHash,

Source§

fn hash(&self, state: &mut impl Update)

Source§

impl<K, V> ContentHash for HashMap<K, V>
where K: ContentHash + Ord, V: ContentHash,

Source§

fn hash(&self, state: &mut impl Update)

Source§

impl<K> ContentHash for HashSet<K>
where K: ContentHash + Ord,

Source§

fn hash(&self, state: &mut impl Update)

Source§

impl<T0, T1, T2, T3> ContentHash for (T0, T1, T2, T3)

Source§

fn hash(&self, state: &mut impl Update)

Source§

impl<T0, T1, T2> ContentHash for (T0, T1, T2)
where T0: ContentHash, T1: ContentHash, T2: ContentHash,

Source§

fn hash(&self, state: &mut impl Update)

Source§

impl<T0, T1> ContentHash for (T0, T1)
where T0: ContentHash, T1: ContentHash,

Source§

fn hash(&self, state: &mut impl Update)

Source§

impl<T0> ContentHash for (T0,)
where T0: ContentHash,

Source§

fn hash(&self, state: &mut impl Update)

Source§

impl<T> ContentHash for Option<T>
where T: ContentHash,

Source§

fn hash(&self, state: &mut impl Update)

Source§

impl<T> ContentHash for Vec<T>
where T: ContentHash,

Source§

fn hash(&self, state: &mut impl Update)

Source§

impl<T> ContentHash for [T]
where T: ContentHash,

Source§

fn hash(&self, state: &mut impl Update)

Implementors§