alloy_hardforks/hardfork/
mod.rs1mod macros;
2
3mod ethereum;
4pub use ethereum::*;
5
6use alloc::boxed::Box;
7use core::{
8 any::Any,
9 hash::{Hash, Hasher},
10};
11use dyn_clone::DynClone;
12
13#[auto_impl::auto_impl(&, Box)]
15pub trait Hardfork: Any + DynClone + Send + Sync + 'static {
16 fn name(&self) -> &'static str;
18
19 fn boxed(&self) -> Box<dyn Hardfork + '_> {
21 Box::new(self)
22 }
23}
24
25dyn_clone::clone_trait_object!(Hardfork);
26
27impl core::fmt::Debug for dyn Hardfork + 'static {
28 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
29 f.debug_struct(self.name()).finish()
30 }
31}
32
33impl PartialEq for dyn Hardfork + 'static {
34 fn eq(&self, other: &Self) -> bool {
35 self.name() == other.name()
36 }
37}
38
39impl Eq for dyn Hardfork + 'static {}
40
41impl Hash for dyn Hardfork + 'static {
42 fn hash<H: Hasher>(&self, state: &mut H) {
43 self.name().hash(state)
44 }
45}