EntityToDefinition

Trait EntityToDefinition 

Source
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 formation
  • Formed : The final type that results from the formation process
  • End : The ending condition or operation for the formation process

§Associated Types

§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§

Source

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.

Source

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.

Implementations on Foreign Types§

Source§

impl<E, Context, Formed, End> EntityToDefinition<Context, Formed, End> for BinaryHeap<E>
where E: Ord, End: FormingEnd<BinaryHeapDefinitionTypes<E, Context, Formed>>,

Source§

type Definition = BinaryHeapDefinition<E, Context, Formed, End>

Source§

type Types = BinaryHeapDefinitionTypes<E, Context, Formed>

Source§

impl<E, Context, Formed, End> EntityToDefinition<Context, Formed, End> for BTreeSet<E>
where End: FormingEnd<BTreeSetDefinitionTypes<E, Context, Formed>>,

Source§

type Definition = BTreeSetDefinition<E, Context, Formed, End>

Source§

type Types = BTreeSetDefinitionTypes<E, Context, Formed>

Source§

impl<E, Context, Formed, End> EntityToDefinition<Context, Formed, End> for LinkedList<E>
where End: FormingEnd<LinkedListDefinitionTypes<E, Context, Formed>>,

Source§

type Definition = LinkedListDefinition<E, Context, Formed, End>

Source§

type Types = LinkedListDefinitionTypes<E, Context, Formed>

Source§

impl<E, Context, Formed, End> EntityToDefinition<Context, Formed, End> for VecDeque<E>
where End: FormingEnd<VecDequeDefinitionTypes<E, Context, Formed>>,

Source§

type Definition = VecDequeDefinition<E, Context, Formed, End>

Source§

type Types = VecDequeDefinitionTypes<E, Context, Formed>

Source§

impl<E, Context, Formed, End> EntityToDefinition<Context, Formed, End> for Vec<E>
where End: FormingEnd<VectorDefinitionTypes<E, Context, Formed>>,

Source§

type Definition = VectorDefinition<E, Context, Formed, End>

Source§

type Types = VectorDefinitionTypes<E, Context, Formed>

Source§

impl<K, Context, Formed, End> EntityToDefinition<Context, Formed, End> for HashSet<K>
where K: Eq + Hash, End: FormingEnd<HashSetDefinitionTypes<K, Context, Formed>>,

Source§

type Definition = HashSetDefinition<K, Context, Formed, End>

Source§

type Types = HashSetDefinitionTypes<K, Context, Formed>

Source§

impl<K, E, Context, Formed, End> EntityToDefinition<Context, Formed, End> for BTreeMap<K, E>
where K: Ord, End: FormingEnd<BTreeMapDefinitionTypes<K, E, Context, Formed>>,

Source§

type Definition = BTreeMapDefinition<K, E, Context, Formed, End>

Source§

type Types = BTreeMapDefinitionTypes<K, E, Context, Formed>

Source§

impl<K, E, Context, Formed, End> EntityToDefinition<Context, Formed, End> for HashMap<K, E>
where K: Eq + Hash, End: FormingEnd<HashMapDefinitionTypes<K, E, Context, Formed>>,

Source§

type Definition = HashMapDefinition<K, E, Context, Formed, End>

Source§

type Types = HashMapDefinitionTypes<K, E, Context, Formed>

Implementors§