Skip to main content

ContentHash

Trait ContentHash 

Source
pub trait ContentHash {
    // Required method
    fn hash(&self, state: &mut impl DigestUpdate);
}
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 DigestUpdate)

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", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ContentHash for bool

Source§

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

Source§

impl ContentHash for i32

Source§

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

Source§

impl ContentHash for i64

Source§

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

Source§

impl ContentHash for str

Source§

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

Source§

impl ContentHash for u8

Source§

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

Source§

impl ContentHash for u32

Source§

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

Source§

impl ContentHash for u64

Source§

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

Source§

impl ContentHash for ()

Source§

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

Source§

impl ContentHash for String

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<T: ContentHash> ContentHash for [T]

Source§

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

Source§

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

Source§

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

Implementors§