Trait frame_support::storage::types::KeyGenerator
source · pub trait KeyGenerator {
type Key: EncodeLike<Self::Key> + StaticTypeInfo;
type KArg: Encode;
type HashFn: FnOnce(&[u8]) -> Vec<u8>;
type HArg;
const HASHER_METADATA: &'static [StorageHasher];
fn final_key<KArg: EncodeLikeTuple<Self::KArg> + TupleToEncodedIter>(
key: KArg
) -> Vec<u8> ⓘ;
fn migrate_key<KArg: EncodeLikeTuple<Self::KArg> + TupleToEncodedIter>(
key: &KArg,
hash_fns: Self::HArg
) -> Vec<u8> ⓘ;
}
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>
type HArg
Required Associated Constants§
const HASHER_METADATA: &'static [StorageHasher]
Required Methods§
sourcefn final_key<KArg: EncodeLikeTuple<Self::KArg> + TupleToEncodedIter>(
key: KArg
) -> Vec<u8> ⓘ
fn final_key<KArg: EncodeLikeTuple<Self::KArg> + TupleToEncodedIter>(
key: KArg
) -> Vec<u8> ⓘ
Given a key
tuple, calculate the final key by encoding each element individually and
hashing them using the corresponding hasher in the KeyGenerator
.
sourcefn migrate_key<KArg: EncodeLikeTuple<Self::KArg> + TupleToEncodedIter>(
key: &KArg,
hash_fns: Self::HArg
) -> Vec<u8> ⓘ
fn migrate_key<KArg: EncodeLikeTuple<Self::KArg> + TupleToEncodedIter>(
key: &KArg,
hash_fns: Self::HArg
) -> Vec<u8> ⓘ
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
.