Trait pallet_roles::storage::types::KeyGenerator
pub trait KeyGenerator {
type Key: EncodeLike<Self::Key> + StaticTypeInfo;
type KArg: Encode;
type HashFn: FnOnce(&[u8]) -> Vec<u8, Global>;
type HArg;
const HASHER_METADATA: &'static [StorageHasher];
fn final_key<KArg>(key: KArg) -> Vec<u8, Global> ⓘ
where
KArg: EncodeLikeTuple<Self::KArg> + TupleToEncodedIter;
fn migrate_key<KArg>(key: &KArg, hash_fns: Self::HArg) -> Vec<u8, Global> ⓘ
where
KArg: EncodeLikeTuple<Self::KArg> + TupleToEncodedIter;
}
Expand description
A trait that contains the current key as an associated type.
Required Associated Types§
type Key: EncodeLike<Self::Key> + StaticTypeInfo
type KArg: Encode
type HashFn: FnOnce(&[u8]) -> Vec<u8, Global>
type HArg
Required Associated Constants§
const HASHER_METADATA: &'static [StorageHasher]
Required Methods§
fn final_key<KArg>(key: KArg) -> Vec<u8, Global> ⓘwhere
KArg: EncodeLikeTuple<Self::KArg> + TupleToEncodedIter,
fn final_key<KArg>(key: KArg) -> Vec<u8, Global> ⓘwhere
KArg: EncodeLikeTuple<Self::KArg> + TupleToEncodedIter,
Given a key
tuple, calculate the final key by encoding each element individually and
hashing them using the corresponding hasher in the KeyGenerator
.
fn migrate_key<KArg>(key: &KArg, hash_fns: Self::HArg) -> Vec<u8, Global> ⓘwhere
KArg: EncodeLikeTuple<Self::KArg> + TupleToEncodedIter,
fn migrate_key<KArg>(key: &KArg, hash_fns: Self::HArg) -> Vec<u8, Global> ⓘwhere
KArg: EncodeLikeTuple<Self::KArg> + TupleToEncodedIter,
Given a key
tuple, migrate the keys from using the old hashers as given by hash_fns
to using the newer hashers as specified by this KeyGenerator
.