@@ -107,8 +107,7 @@ pub fn with_transaction<R>(f: impl FnOnce() -> TransactionOutcome<R>) -> R {
107
107
108
108
/// A trait for working with macro-generated storage values under the substrate storage API.
109
109
///
110
- /// Details on implementation can be found at
111
- /// [`generator::StorageValue`]
110
+ /// Details on implementation can be found at [`generator::StorageValue`].
112
111
pub trait StorageValue < T : FullCodec > {
113
112
/// The type that get/take return.
114
113
type Query ;
@@ -122,8 +121,9 @@ pub trait StorageValue<T: FullCodec> {
122
121
/// Load the value from the provided storage instance.
123
122
fn get ( ) -> Self :: Query ;
124
123
125
- /// Try to get the underlying value from the provided storage instance; `Ok` if it exists,
126
- /// `Err` if not.
124
+ /// Try to get the underlying value from the provided storage instance.
125
+ ///
126
+ /// Returns `Ok` if it exists, `Err` if not.
127
127
fn try_get ( ) -> Result < T , ( ) > ;
128
128
129
129
/// Translate a value from some previous type (`O`) to the current type.
@@ -200,8 +200,7 @@ pub trait StorageValue<T: FullCodec> {
200
200
201
201
/// A strongly-typed map in storage.
202
202
///
203
- /// Details on implementation can be found at
204
- /// [`generator::StorageMap`]
203
+ /// Details on implementation can be found at [`generator::StorageMap`].
205
204
pub trait StorageMap < K : FullEncode , V : FullCodec > {
206
205
/// The type that get/take return.
207
206
type Query ;
@@ -215,6 +214,11 @@ pub trait StorageMap<K: FullEncode, V: FullCodec> {
215
214
/// Load the value associated with the given key from the map.
216
215
fn get < KeyArg : EncodeLike < K > > ( key : KeyArg ) -> Self :: Query ;
217
216
217
+ /// Try to get the value for the given key from the map.
218
+ ///
219
+ /// Returns `Ok` if it exists, `Err` if not.
220
+ fn try_get < KeyArg : EncodeLike < K > > ( key : KeyArg ) -> Result < V , ( ) > ;
221
+
218
222
/// Swap the values of two keys.
219
223
fn swap < KeyArg1 : EncodeLike < K > , KeyArg2 : EncodeLike < K > > ( key1 : KeyArg1 , key2 : KeyArg2 ) ;
220
224
@@ -233,7 +237,9 @@ pub trait StorageMap<K: FullEncode, V: FullCodec> {
233
237
f : F ,
234
238
) -> Result < R , E > ;
235
239
236
- /// Mutate the value under a key. Deletes the item if mutated to a `None`.
240
+ /// Mutate the value under a key.
241
+ ///
242
+ /// Deletes the item if mutated to a `None`.
237
243
fn mutate_exists < KeyArg : EncodeLike < K > , R , F : FnOnce ( & mut Option < V > ) -> R > ( key : KeyArg , f : F ) -> R ;
238
244
239
245
/// Mutate the item, only if an `Ok` value is returned. Deletes the item if mutated to a `None`.
@@ -354,8 +360,7 @@ pub trait IterableStorageDoubleMap<
354
360
/// It provides an important ability to efficiently remove all entries
355
361
/// that have a common first key.
356
362
///
357
- /// Details on implementation can be found at
358
- /// [`generator::StorageDoubleMap`]
363
+ /// Details on implementation can be found at [`generator::StorageDoubleMap`].
359
364
pub trait StorageDoubleMap < K1 : FullEncode , K2 : FullEncode , V : FullCodec > {
360
365
/// The type that get/take returns.
361
366
type Query ;
@@ -378,6 +383,14 @@ pub trait StorageDoubleMap<K1: FullEncode, K2: FullEncode, V: FullCodec> {
378
383
KArg1 : EncodeLike < K1 > ,
379
384
KArg2 : EncodeLike < K2 > ;
380
385
386
+ /// Try to get the value for the given key from the double map.
387
+ ///
388
+ /// Returns `Ok` if it exists, `Err` if not.
389
+ fn try_get < KArg1 , KArg2 > ( k1 : KArg1 , k2 : KArg2 ) -> Result < V , ( ) >
390
+ where
391
+ KArg1 : EncodeLike < K1 > ,
392
+ KArg2 : EncodeLike < K2 > ;
393
+
381
394
/// Take a value from storage, removing it afterwards.
382
395
fn take < KArg1 , KArg2 > ( k1 : KArg1 , k2 : KArg2 ) -> Self :: Query
383
396
where
0 commit comments