pub trait EntityToDefinition<Context, Formed, End> {
type Definition: FormerDefinition;
type Types: FormerDefinitionTypes;
}Expand description
Maps a type of entity to its corresponding former definition.
This trait establishes a fundamental relationship in the Former pattern by linking an entity type to its complete formation definition. It serves as the bridge between the user’s struct/enum and the generated Former ecosystem.
§Type Parameters
Context: The contextual information available during formationFormed: The final type that results from the formation processEnd: The ending condition or operation for the formation process
§Associated Types
- [
Definition] : The completeFormerDefinitionthat governs this entity’s formation - [
Types] : The type system integration viaFormerDefinitionTypes
§Usage in Generated Code
This trait is automatically implemented by the #[ derive( Former ) ] macro and should
not typically be implemented manually. It enables the Former pattern to :
- Determine the correct storage type for an entity
- Link to the appropriate former struct
- Apply the correct formation logic
- Handle generic parameters and constraints properly
§Example Context
// For a struct like this :
#[ derive( Former ) ]
struct User { name: String, age: u32 }
// The macro generates an implementation like :
impl EntityToDefinition< (), User, former ::ReturnPreformed > for User
{
type Definition = UserDefinition;
type Types = UserDefinitionTypes;
}Required Associated Types§
Sourcetype Definition: FormerDefinition
type Definition: FormerDefinition
The specific FormerDefinition associated with this entity.
This definition contains all the information needed to construct instances of the entity, including storage types, formation logic, and completion handlers.
Sourcetype Types: FormerDefinitionTypes
type Types: FormerDefinitionTypes
The specific FormerDefinitionTypes associated with this entity.
These types provide the type system integration, defining the storage, formed result, and context types used throughout the formation process.