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
use hash::H256;
#[cfg_attr(not(feature="std"), link(name = "env"))]
extern {
fn storage_read(key: *const u8, dst: *mut u8);
fn storage_write(key: *const u8, src: *const u8);
}
pub fn read(key: &H256) -> [u8; 32] {
let mut dst = [0u8; 32];
unsafe {
storage_read(key.as_ptr(), dst.as_mut_ptr());
}
dst
}
pub fn write(key: &H256, val: &[u8; 32]) {
unsafe {
storage_write(key.as_ptr(), val.as_ptr());
}
}