[][src]Trait frame_support::storage::StoragePrefixedMap

pub trait StoragePrefixedMap<Value: FullCodec> {
    fn module_prefix() -> &'static [u8]

Notable traits for &'_ mut [u8]

impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
;
fn storage_prefix() -> &'static [u8]

Notable traits for &'_ mut [u8]

impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
; fn final_prefix() -> [u8; 32] { ... }
fn remove_all() { ... }
fn iter_values() -> PrefixIterator<Value>

Notable traits for PrefixIterator<Value>

impl<Value: Decode> Iterator for PrefixIterator<Value> type Item = Value;
{ ... }
fn translate_values<OldValue, TV>(translate_val: TV) -> Result<(), u32>
    where
        OldValue: Decode,
        TV: Fn(OldValue) -> Value
, { ... } }

Trait for maps that store all its value after a unique prefix.

By default the final prefix is:

Twox128(module_prefix) ++ Twox128(storage_prefix)

Required methods

fn module_prefix() -> &'static [u8]

Notable traits for &'_ mut [u8]

impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]

Module prefix. Used for generating final key.

fn storage_prefix() -> &'static [u8]

Notable traits for &'_ mut [u8]

impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]

Storage prefix. Used for generating final key.

Loading content...

Provided methods

fn final_prefix() -> [u8; 32]

Final full prefix that prefixes all keys.

fn remove_all()

Remove all value of the storage.

fn iter_values() -> PrefixIterator<Value>

Notable traits for PrefixIterator<Value>

impl<Value: Decode> Iterator for PrefixIterator<Value> type Item = Value;

Iter over all value of the storage.

fn translate_values<OldValue, TV>(translate_val: TV) -> Result<(), u32> where
    OldValue: Decode,
    TV: Fn(OldValue) -> Value, 

Translate the values from some previous OldValue to the current type.

TV translates values.

Returns Err if the map could not be interpreted as the old type, and Ok if it could. The Err contains the number of value that couldn't be interpreted, those value are removed from the map.

Warning

This function must be used with care, before being updated the storage still contains the old type, thus other calls (such as get) will fail at decoding it.

Usage

This would typically be called inside the module implementation of on_runtime_upgrade, while ensuring no usage of this storage are made before the call to on_runtime_upgrade. (More precisely prior initialized modules doesn't make use of this storage).

Loading content...

Implementors

Loading content...