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§
Sourceconst STORAGE_PREFIX: &'static str
const STORAGE_PREFIX: &'static str
Prefix given to a storage to isolate from other storages in the pallet.
Required Methods§
Sourcefn pallet_prefix() -> &'static str
fn pallet_prefix() -> &'static str
Prefix of a pallet to isolate it from other pallets.
Provided Methods§
Sourcefn pallet_prefix_hash() -> [u8; 16]
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.
Sourcefn storage_prefix_hash() -> [u8; 16]
fn storage_prefix_hash() -> [u8; 16]
Return the prefix hash of storage instance.
NOTE: This hash must be twox_128(STORAGE_PREFIX)
.
Sourcefn prefix_hash() -> [u8; 32]
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.