1construct_uint! {
5 #[derive(Serialize, Deserialize)]
7 pub struct U256(4);
8}
9
10construct_fixed_hash! {
11 #[derive(Serialize, Deserialize)]
13 pub struct H160(20);
14}
15
16construct_fixed_hash! {
17 #[derive(Serialize, Deserialize)]
19 pub struct H256(32);
20}
21
22impl_fixed_hash_conversions!(H256, H160);
24
25pub type Address = H160;
27
28impl From<U256> for H256 {
29 fn from(uint: U256) -> H256 {
30 let mut hash = H256::zero();
31 uint.to_big_endian(hash.as_bytes_mut());
32 hash
33 }
34}
35
36impl<'a> From<&'a U256> for H256 {
37 fn from(uint: &'a U256) -> H256 {
38 let mut hash: H256 = H256::zero();
39 uint.to_big_endian(hash.as_bytes_mut());
40 hash
41 }
42}
43
44impl From<H256> for U256 {
45 fn from(hash: H256) -> U256 {
46 U256::from(hash.as_bytes())
47 }
48}
49
50impl<'a> From<&'a H256> for U256 {
51 fn from(hash: &'a H256) -> U256 {
52 U256::from(hash.as_bytes())
53 }
54}