@@ -123,6 +123,19 @@ The derived implementation contains conversions both direction as well as update
123
123
* `alternative <C >(self , other : Schematic <C >) -> Schematic <Result <A , C >>`
124
124
* `filter <F : Fn (& A ) -> bool >(self , f : F ) -> Schematic <A >`
125
125
126
+ ### Adding schematics to your app
127
+
128
+ `Schematic `s can be added to the app using
129
+ ```rust
130
+ app . add_schematic (AnimationState :: default_schematic ());
131
+ ```
132
+
133
+ Since with many components you want to just copy the same component from the schematic to the main world, a ` CloneSchematic<A: Clone> ` is provided.
134
+
135
+ ``` rust
136
+ app . add_schematic (CloneSchematic :: <Visibility >:: default ());
137
+ ```
138
+
126
139
### Creating ` Schematic ` manually
127
140
128
141
` Schematic<A> ` can be constructed manually using the ` new ` function
@@ -132,16 +145,16 @@ where
132
145
S : IntoSchematicConversion
133
146
```
134
147
135
- You can add conversion in the other direction by using the `add_inference ` function
148
+ You can add conversion in the other direction by using the `set_inference ` function
136
149
```rust
137
- fn add_inference <S >(self , system : S ) -> Schematic <A >
150
+ fn set_inference <S >(self , system : S ) -> Schematic <A >
138
151
where
139
152
S : IntoSchematicInference <Component = A >
140
153
```
141
154
142
- Finally you can add updates by using the `add_update ` function
155
+ Finally you can add updates by using the `set_update ` function
143
156
```rust
144
- fn add_udpate <S >(self , system : S ) -> Schematic <A >
157
+ fn set_udpate <S >(self , system : S ) -> Schematic <A >
145
158
where
146
159
S : IntoSchematicUpdate <Component = A >
147
160
```
@@ -273,17 +286,32 @@ fn update_animation_state(
273
286
}
274
287
```
275
288
276
- ### Adding schematics to your app
289
+ ### ` UntypedSchematic `
277
290
278
- ` Schematic ` s can be added to the app using
291
+ A ` UntypedSchematic ` is the same as a ` Schematic ` just without the type restriction.
292
+ Usually it is safer to use the ` Schematic ` interface, but you might want to handle multiple schematic components within the same system.
293
+ Not having an associated type means, that the ` map ` , ` zip ` , ` alternative ` and ` filter ` methods are not available for ` UntypedSchematic ` .
294
+
295
+ ` UntypedSchematic ` can be constructed manually using the ` new ` function
279
296
``` rust
280
- app . add_schematic (AnimationState :: default_schematic ());
297
+ fn new <S >(system : S ) -> UntypedSchematic
298
+ where
299
+ S : IntoSchematicConversion
281
300
```
282
301
283
- Since with many components you want to just copy the same component from the schematic to the main world, a ` CloneSchematic<A: Clone> ` is provided.
302
+ You can add conversion in the other direction by using the `set_inference ` function .
303
+ ```rust
304
+ fn set_inference (self , system : S ) -> UntypedSchematic
305
+ where
306
+ S : IntoSchematicInference
307
+ ```
284
308
309
+ Finally you can add updates by using the `add_update ` function .
310
+ This will not replace any systems added previously by this method .
285
311
```rust
286
- app . add_schematic (CloneSchematic :: <Visibility >:: default ());
312
+ fn add_udpate <S >(self , system : S ) -> UntypedSchematic
313
+ where
314
+ S : IntoSchematicUpdate
287
315
```
288
316
289
317
## Implementation strategy
@@ -305,9 +333,18 @@ app.add_schematic(CloneSchematic::<Visibility>::default());
305
333
* ` Schematic ` is
306
334
``` rust
307
335
struct Schematic <A > {
308
- conversion : Box <dyn SchematicConversion <A >>,
309
- inference : Option <Box <dyn SchematicInference <A >>>,
310
- update : Option <Box <dyn SchematicUpdate <A >>>,
336
+ marker : PhantomMarker <A >,
337
+ conversion : Box <dyn SchematicConversion <Component = A >>,
338
+ inference : Option <Box <dyn SchematicInference <Component = A >>>,
339
+ update : Option <Box <dyn SchematicUpdate <Component = A >>>,
340
+ }
341
+ ```
342
+ * ` UntypedSchematic ` is
343
+ ``` rust
344
+ struct UntypedSchematic {
345
+ conversion : Vec <Box <dyn SchematicConversion >>,
346
+ inference : Vec <Box <dyn SchematicInference >>,
347
+ update : Vec <Box <dyn SchematicUpdate >>,
311
348
}
312
349
```
313
350
* ` SchematicConversion ` , ` SchematicInference ` and ` SchematicUpdate ` are basically just ` System ` with a restriction on the parameters
0 commit comments