pub trait KeyGenFor<Id, Item, Salt, Hasher, T>{
// Provided method
fn gen_key(target: &Id, item: &Item, salt: Salt) -> Option<Id> { ... }
}Expand description
Trait for generating deterministic identifiers from a combination of key, item, and salt.
This trait abstracts the process of deriving a unique, reproducible identifier (Id)
from a source key (target), associated item (metadata), and a salt value, using
a specified hashing algorithm.
It is intended for use cases where deterministic, namespaced, or context-specific IDs are required, such as sub-identities, capability delegation, or resource handles.
§Type Parameters
Id: The identifier type to be generated and used as the source key.Item: The metadata or context value associated with the identifier.Salt: A unique value to ensure uniqueness per(Id, Item)pair.Hasher: The hashing algorithm used for deterministic ID derivation.T: The runtime context (e.g., a Substrate pallet’sConfig).
Provided Methods§
Sourcefn gen_key(target: &Id, item: &Item, salt: Salt) -> Option<Id>
fn gen_key(target: &Id, item: &Item, salt: Salt) -> Option<Id>
Generates a deterministic identifier (Id) from the given target, item,
and salt.
This method constructs a KeySeedFor instance and invokes its key_gen
method, ensuring that the same input combination always produces the same
output identifier.
Returns Some(Id) if key generation succeeds, or None if decoding from
the hash output fails.
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.
Implementors§
impl<Id, Item, Salt, Hasher, T> KeyGenFor<Id, Item, Salt, Hasher, T> for KeySeedFor<Id, Item, Salt, Hasher, T>
Blanket implementation of KeyGenFor for KeySeedFor.
This allows any KeySeedFor instance to use the gen_key utility