1use crate::asm;
4pub use {
5 dkmapping::{DoubleKeyMapping, DoubleKeyTransientMapping},
6 mapping::{Mapping, TransientMapping},
7 value::{Storage, TransientStorage},
8};
9
10pub mod dkmapping;
11pub mod mapping;
12mod value;
13
14pub trait Value {
16 fn sload() -> Self;
18
19 fn tload() -> Self;
21
22 fn push(self);
24
25 #[cfg(not(target_family = "wasm"))]
27 fn bytes32(&self) -> [u8; 32];
28}
29
30macro_rules! impl_value {
31 ($($ty:ident),+) => {
32 $(
33 paste::paste! {
34 impl Value for $ty {
35 fn sload() -> Self {
36 unsafe { asm::ext::[<sload_ $ty>]() }
37 }
38
39 fn tload() -> Self {
40 unsafe { asm::ext::[<tload_ $ty>]() }
41 }
42
43 fn push(self) {
44 unsafe { asm::ext::[<push_ $ty>](self); }
45 }
46
47 #[cfg(not(target_family = "wasm"))]
48 fn bytes32(&self) -> [u8; 32] {
49 crate::to_bytes32(&self.to_le_bytes())
50 }
51 }
52 }
53 )+
54 };
55}
56
57impl_value!(i8, u8, i16, u16, i32, u32, i64, u64);