1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
//! Module `definition`
//!
//! Provides traits for defining the relationships between entities and their formation mechanisms.
//! These traits are central to the implementation of a flexible and extensible formation system,
//! enabling entities to be constructed using various configurations and complex logic.
//!
//! Key aspects of the module include :
//! - **Entity to Definition Mapping** : Linking entities to their specific formation definitions,
//! which detail how they are to be constructed.
//! - **Entity to Former Mapping** : Associating entities with formers that handle their construction
//! process.
//! - **Entity to Storage Mapping** : Defining the storage structures that maintain the state of an
//! entity during its formation.
//! - **Definition Traits** : Specifying the properties and ending conditions of the formation
//! process to ensure entities are formed according to specified rules and logic.
//!
/// 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
/// - [`Definition`] : The complete [`FormerDefinition`] that governs this entity's formation
/// - [`Types`] : The type system integration via [`FormerDefinitionTypes`]
///
/// # 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
/// ```rust, ignore
/// // 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;
/// }
/// ```
/// Provides a mapping between a type of entity and its associated formation type definitions.
///
/// This trait is a simplified version of [`EntityToDefinition`] that focuses purely on type
/// relationships without requiring end condition specification. It's particularly useful
/// in scenarios where the formation logic needs to understand type relationships without
/// needing complete formation control.
///
/// # Type Parameters
/// - `Context` : The contextual information available during formation
/// - `Formed` : The final type that results from the formation process
///
/// # Purpose and Usage
/// This trait serves as a building block for more complex formation scenarios :
/// - Type system integration for subforms
/// - Generic parameter propagation in nested structures
/// - Context type determination in hierarchical builders
/// - Storage type resolution for complex generic scenarios
///
/// # Relationship to Other Traits
/// - Simpler than [`EntityToDefinition`] as it doesn't specify end conditions
/// - Used internally by the Former macro for type resolution
/// - Enables proper generic parameter handling in complex hierarchies
/// Maps a type of entity to its corresponding former (builder) implementation.
///
/// This trait establishes the connection between an entity and its builder struct,
/// enabling the Former pattern to instantiate the correct builder type for a given entity.
/// It's a crucial part of the type system that ensures type safety across the formation process.
///
/// # Type Parameters
/// - `Definition` : The [`FormerDefinition`] that governs the formation process
///
/// # Purpose and Design
/// This trait enables :
/// - **Type-Safe Builder Resolution** : Ensures the correct builder is used for each entity
/// - **Generic Parameter Preservation** : Maintains generic constraints through builder creation
/// - **Custom Former Support** : Allows for specialized builder implementations
/// - **Subform Integration** : Enables nested builders with proper type relationships
///
/// # Usage in Generated Code
/// The `#[ derive( Former ) ]` macro automatically implements this trait :
/// ```rust, ignore
/// // For a struct like :
/// #[ derive( Former ) ]
/// struct Config { setting: String }
///
/// // The macro generates :
/// impl EntityToFormer< ConfigDefinition > for Config
/// {
/// type Former = ConfigFormer< ConfigDefinition >;
/// }
/// ```
///
/// # Integration Points
/// This trait works with :
/// - [`EntityToDefinition`] : For complete entity-to-formation mapping
/// - [`FormerBegin`] : For initiating the formation process
/// - Generated former structs: For the actual builder implementation
/// Maps a type of entity to its storage type.
/// This trait defines what storage structure is used to hold the interim state
/// of an entity during its formation.
/// Defines the fundamental components involved in the formation of an entity.
/// This trait specifies the types of storage, the formed entity, and the context
/// used during the formation process.
/// Expands on `FormerDefinitionTypes` by incorporating an ending mechanism for the formation process.
/// This trait connects the formation types with a specific endpoint, defining
/// how the formation process concludes, including any necessary transformations
/// or validations.