pub trait KeyGenerator {
type Key: EncodeLike<Self::Key> + StaticTypeInfo;
type KArg: Encode + EncodeLike<Self::KArg>;
type HashFn: FnOnce(&[u8]) -> Vec<u8>;
type HArg;
const HASHER_METADATA: &'static [StorageHasherIR];
// Required methods
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 Constants§
const HASHER_METADATA: &'static [StorageHasherIR]
Required Associated Types§
type Key: EncodeLike<Self::Key> + StaticTypeInfo
type KArg: Encode + EncodeLike<Self::KArg>
type HashFn: FnOnce(&[u8]) -> Vec<u8>
type HArg
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.
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.