Trait frame_support::traits::StorageInstance

source ·
pub trait StorageInstance {
    const STORAGE_PREFIX: &'static str;

    // Required method
    fn pallet_prefix() -> &'static str;

    // Provided methods
    fn pallet_prefix_hash() -> [u8; 16] { ... }
    fn storage_prefix_hash() -> [u8; 16] { ... }
    fn prefix_hash() -> [u8; 32] { ... }
}
Expand description

An instance of a storage in a pallet.

Define an instance for an individual storage inside a pallet. The pallet prefix is used to isolate the storage between pallets, and the storage prefix is used to isolate storages inside a pallet.

NOTE: These information can be used to define storages in pallet such as a StorageMap which can use keys after twox_128(pallet_prefix())++twox_128(STORAGE_PREFIX)

Required Associated Constants§

source

const STORAGE_PREFIX: &'static str

Prefix given to a storage to isolate from other storages in the pallet.

Required Methods§

source

fn pallet_prefix() -> &'static str

Prefix of a pallet to isolate it from other pallets.

Provided Methods§

source

fn pallet_prefix_hash() -> [u8; 16]

Return the prefix hash of pallet instance.

NOTE: This hash must be twox_128(pallet_prefix()). Should not impl this function by hand. Only use the default or macro generated impls.

source

fn storage_prefix_hash() -> [u8; 16]

Return the prefix hash of storage instance.

NOTE: This hash must be twox_128(STORAGE_PREFIX).

source

fn prefix_hash() -> [u8; 32]

Return the prefix hash of instance.

NOTE: This hash must be twox_128(pallet_prefix())++twox_128(STORAGE_PREFIX). Should not impl this function by hand. Only use the default or macro generated impls.

Object Safety§

This trait is not object safe.

Implementors§