soroban_env_common/
hash.rs

1//! These Hash impls exist strictly for use in soroban-env-host's tracing
2//! subsystem. Since they do not "look through" to the environment they are
3//! misleading and potentially dangerous to expose for general use.
4
5use crate::{
6    AddressObject, BytesObject, DurationObject, I128Object, I256Object, I64Object, MapObject,
7    Object, StringObject, Symbol, SymbolObject, TimepointObject, U128Object, U256Object, U64Object,
8    Val, VecObject,
9};
10
11impl core::hash::Hash for Val {
12    fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
13        self.get_payload().hash(state);
14    }
15}
16
17macro_rules! impl_hash_for_wrapper {
18    ($WRAPPER:ident) => {
19        impl core::hash::Hash for $WRAPPER {
20            fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
21                self.as_val().get_payload().hash(state);
22            }
23        }
24    };
25}
26
27impl_hash_for_wrapper!(Object);
28impl_hash_for_wrapper!(U64Object);
29impl_hash_for_wrapper!(I64Object);
30impl_hash_for_wrapper!(TimepointObject);
31impl_hash_for_wrapper!(DurationObject);
32impl_hash_for_wrapper!(U128Object);
33impl_hash_for_wrapper!(I128Object);
34impl_hash_for_wrapper!(U256Object);
35impl_hash_for_wrapper!(I256Object);
36impl_hash_for_wrapper!(BytesObject);
37impl_hash_for_wrapper!(StringObject);
38impl_hash_for_wrapper!(SymbolObject);
39impl_hash_for_wrapper!(Symbol);
40impl_hash_for_wrapper!(VecObject);
41impl_hash_for_wrapper!(MapObject);
42impl_hash_for_wrapper!(AddressObject);