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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
use super::unhashed;
use sp_std::prelude::*;
use codec::{Encode, Decode};
pub fn get<T, HashFn, R>(hash: &HashFn, key: &[u8]) -> Option<T>
where
T: Decode + Sized,
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::get(&hash(key).as_ref())
}
pub fn get_or_default<T, HashFn, R>(hash: &HashFn, key: &[u8]) -> T
where
T: Decode + Sized + Default,
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::get_or_default(&hash(key).as_ref())
}
pub fn get_or<T, HashFn, R>(hash: &HashFn, key: &[u8], default_value: T) -> T
where
T: Decode + Sized,
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::get_or(&hash(key).as_ref(), default_value)
}
pub fn get_or_else<T, F, HashFn, R>(hash: &HashFn, key: &[u8], default_value: F) -> T
where
T: Decode + Sized,
F: FnOnce() -> T,
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::get_or_else(&hash(key).as_ref(), default_value)
}
pub fn put<T, HashFn, R>(hash: &HashFn, key: &[u8], value: &T)
where
T: Encode,
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::put(&hash(key).as_ref(), value)
}
pub fn take<T, HashFn, R>(hash: &HashFn, key: &[u8]) -> Option<T>
where
T: Decode + Sized,
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::take(&hash(key).as_ref())
}
pub fn take_or_default<T, HashFn, R>(hash: &HashFn, key: &[u8]) -> T
where
T: Decode + Sized + Default,
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::take_or_default(&hash(key).as_ref())
}
pub fn take_or<T, HashFn, R>(hash: &HashFn, key: &[u8], default_value: T) -> T
where
T: Decode + Sized,
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::take_or(&hash(key).as_ref(), default_value)
}
pub fn take_or_else<T, F, HashFn, R>(hash: &HashFn, key: &[u8], default_value: F) -> T
where
T: Decode + Sized,
F: FnOnce() -> T,
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::take_or_else(&hash(key).as_ref(), default_value)
}
pub fn exists<HashFn, R>(hash: &HashFn, key: &[u8]) -> bool
where
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::exists(&hash(key).as_ref())
}
pub fn kill<HashFn, R>(hash: &HashFn, key: &[u8])
where
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::kill(&hash(key).as_ref())
}
pub fn get_raw<HashFn, R>(hash: &HashFn, key: &[u8]) -> Option<Vec<u8>>
where
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::get_raw(&hash(key).as_ref())
}
pub fn put_raw<HashFn, R>(hash: &HashFn, key: &[u8], value: &[u8])
where
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::put_raw(&hash(key).as_ref(), value)
}