Skip to main content

StableHash

Trait StableHash 

Source
pub trait StableHash {
    // Required method
    fn stable_hash<H>(&self, state: &mut H)
       where H: StableHasher + ?Sized;
}
Expand description

A trait for types that can be hashed in a stable manner.

The trait provides a single method that takes a mutable reference to a StableHasher and feeds the type’s data into the hasher.

§Example

#[derive(Debug)]
struct Point {
    x: i32,
    y: i32,
}

impl StableHash for Point {
    fn stable_hash<H: StableHasher + ?Sized>(&self, state: &mut H) {
        self.x.stable_hash(state);
        self.y.stable_hash(state);
    }
}

let point = Point { x: 10, y: 20 };
let mut hasher = StableSipHasher::new();
point.stable_hash(&mut hasher);
let hash = hasher.finish();

Required Methods§

Source

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Feeds this type’s data into the provided hasher.

Implementations should hash all fields that contribute to the type’s identity in a consistent order. The hash should be stable across different program runs and platforms.

§Arguments
  • state - The hasher to feed data into

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 StableHash for bool

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for char

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for f32

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for f64

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for i8

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for i16

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for i32

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for i64

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for i128

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for isize

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for str

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for u8

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for u16

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for u32

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for u64

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for u128

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for ()

Source§

fn stable_hash<H>(&self, _state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for usize

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for CString

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for String

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for CStr

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for NonZero<i8>

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for NonZero<i16>

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for NonZero<i32>

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for NonZero<i64>

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for NonZero<i128>

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for NonZero<isize>

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for NonZero<u8>

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for NonZero<u16>

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for NonZero<u32>

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for NonZero<u64>

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for NonZero<u128>

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for NonZero<usize>

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for RangeFull

Source§

fn stable_hash<H>(&self, _state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for AtomicBool

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for AtomicI8

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for AtomicI16

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for AtomicI32

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for AtomicI64

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for AtomicIsize

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for AtomicU8

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for AtomicU16

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for AtomicU32

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for AtomicU64

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for AtomicUsize

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for Duration

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for OsStr

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for OsString

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for Path

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for PathBuf

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl StableHash for StableTypeID

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

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

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<K, V, B> StableHash for HashMap<K, V, B>
where K: StableHash, V: StableHash,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<K, V, B> StableHash for ReadOnlyView<K, V, B>
where K: StableHash + Eq + Hash, V: StableHash, B: BuildHasher + Clone,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<K, V, B> StableHash for DashMap<K, V, B>
where K: StableHash + Eq + Hash, V: StableHash, B: BuildHasher + Clone,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T> StableHash for Cow<'_, T>
where T: StableHash + Clone,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

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

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T> StableHash for &T
where T: StableHash + ?Sized,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T> StableHash for &mut T
where T: StableHash + ?Sized,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

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

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T> StableHash for (T,)
where T: StableHash,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T> StableHash for Box<T>
where T: StableHash + ?Sized,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T> StableHash for BinaryHeap<T>
where T: StableHash,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T> StableHash for BTreeSet<T>
where T: StableHash,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T> StableHash for LinkedList<T>
where T: StableHash,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T> StableHash for VecDeque<T>
where T: StableHash,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T> StableHash for Rc<T>
where T: StableHash + ?Sized,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T> StableHash for Arc<T>
where T: StableHash + ?Sized,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

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

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T> StableHash for PhantomData<T>

Source§

fn stable_hash<H>(&self, _state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T> StableHash for Discriminant<T>

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T> StableHash for Range<T>
where T: StableHash,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T> StableHash for RangeFrom<T>
where T: StableHash,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T> StableHash for RangeInclusive<T>
where T: StableHash,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T> StableHash for RangeTo<T>
where T: StableHash,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T> StableHash for RangeToInclusive<T>
where T: StableHash,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T> StableHash for Interned<T>
where T: StableHash + ?Sized,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T, B> StableHash for HashSet<T, B>
where T: StableHash,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T, B> StableHash for DashSet<T, B>
where T: StableHash + Eq + Hash, B: BuildHasher + Clone,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T, E> StableHash for Result<T, E>
where T: StableHash, E: StableHash,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T, U> StableHash for (T, U)
where T: StableHash, U: StableHash,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T, U, V> StableHash for (T, U, V)
where T: StableHash, U: StableHash, V: StableHash,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T, U, V, W> StableHash for (T, U, V, W)

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T, U, V, W, X> StableHash for (T, U, V, W, X)

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T, U, V, W, X, Y> StableHash for (T, U, V, W, X, Y)

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T, U, V, W, X, Y, Z> StableHash for (T, U, V, W, X, Y, Z)

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T, U, V, W, X, Y, Z, A> StableHash for (T, U, V, W, X, Y, Z, A)

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T, U, V, W, X, Y, Z, A, B> StableHash for (T, U, V, W, X, Y, Z, A, B)

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T, U, V, W, X, Y, Z, A, B, C> StableHash for (T, U, V, W, X, Y, Z, A, B, C)

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T, U, V, W, X, Y, Z, A, B, C, D> StableHash for (T, U, V, W, X, Y, Z, A, B, C, D)

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T, U, V, W, X, Y, Z, A, B, C, D, E> StableHash for (T, U, V, W, X, Y, Z, A, B, C, D, E)

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<T, const N: usize> StableHash for [T; N]
where T: StableHash,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Source§

impl<const SIZE: usize, const PAD1: usize, const PAD2: usize, HEAP> StableHash for FlexStr<SIZE, PAD1, PAD2, HEAP>
where HEAP: Deref<Target = str>,

Source§

fn stable_hash<H>(&self, state: &mut H)
where H: StableHasher + ?Sized,

Implementors§