ethrex_trie/
rkyv_utils.rs1use ethereum_types::H256;
2use rkyv::{Archive, Deserialize, Serialize};
3use std::hash::{Hash, Hasher};
4
5#[derive(
6 Archive, Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord,
7)]
8#[rkyv(remote = H256)]
9pub struct H256Wrapper([u8; 32]);
10
11impl From<H256Wrapper> for H256 {
12 fn from(value: H256Wrapper) -> Self {
13 Self(value.0)
14 }
15}
16
17impl PartialEq for ArchivedH256Wrapper {
18 fn eq(&self, other: &Self) -> bool {
19 self.0 == other.0
20 }
21}
22
23impl PartialOrd for ArchivedH256Wrapper {
24 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
25 Some(self.cmp(other))
26 }
27}
28
29impl Ord for ArchivedH256Wrapper {
30 fn cmp(&self, other: &Self) -> std::cmp::Ordering {
31 self.0.cmp(&other.0)
32 }
33}
34
35impl Eq for ArchivedH256Wrapper {}
36
37impl Hash for ArchivedH256Wrapper {
38 fn hash<H: Hasher>(&self, state: &mut H) {
39 self.0.hash(state);
40 }
41}