1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
use U256; construct_hash!(H32, 4); construct_hash!(H64, 8); construct_hash!(H128, 16); construct_hash!(H160, 20); construct_hash!(H256, 32); construct_hash!(H264, 33); construct_hash!(H512, 64); construct_hash!(H520, 65); construct_hash!(H1024, 128); construct_hash!(H2048, 256); impl From<U256> for H256 { fn from(value: U256) -> H256 { let mut ret = H256::new(); value.to_big_endian(&mut ret); ret } } impl<'a> From<&'a U256> for H256 { fn from(value: &'a U256) -> H256 { let mut ret: H256 = H256::new(); value.to_big_endian(&mut ret); ret } } impl From<H256> for U256 { fn from(value: H256) -> U256 { U256::from(&value) } } impl<'a> From<&'a H256> for U256 { fn from(value: &'a H256) -> U256 { U256::from(value.as_ref() as &[u8]) } } impl From<H256> for H160 { fn from(value: H256) -> H160 { let mut ret = H160::new(); ret.0.copy_from_slice(&value[12..32]); ret } } impl From<H256> for H64 { fn from(value: H256) -> H64 { let mut ret = H64::new(); ret.0.copy_from_slice(&value[20..28]); ret } } impl From<H160> for H256 { fn from(value: H160) -> H256 { let mut ret = H256::new(); ret.0[12..32].copy_from_slice(&value); ret } } impl<'a> From<&'a H160> for H256 { fn from(value: &'a H160) -> H256 { let mut ret = H256::new(); ret.0[12..32].copy_from_slice(value); ret } }