@@ -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,33 @@ 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 `add_inference ` function .
303
+ This will not replace any systems added previously by this method .
304
+ ```rust
305
+ fn add_inference (self , system : S ) -> Schematic <A >
306
+ where
307
+ S : IntoSchematicInference
308
+ ```
284
309
310
+ Finally you can add updates by using the `add_update ` function .
311
+ This will not replace any systems added previously by this method .
285
312
```rust
286
- app . add_schematic (CloneSchematic :: <Visibility >:: default ());
313
+ fn add_udpate <S >(self , system : S ) -> Schematic <A >
314
+ where
315
+ S : IntoSchematicUpdate
287
316
```
288
317
289
318
## Implementation strategy
@@ -305,9 +334,18 @@ app.add_schematic(CloneSchematic::<Visibility>::default());
305
334
* ` Schematic ` is
306
335
``` rust
307
336
struct Schematic <A > {
308
- conversion : Box <dyn SchematicConversion <A >>,
309
- inference : Option <Box <dyn SchematicInference <A >>>,
310
- update : Option <Box <dyn SchematicUpdate <A >>>,
337
+ marker : PhantomMarker <A >,
338
+ conversion : Box <dyn SchematicConversion <Component = A >>,
339
+ inference : Option <Box <dyn SchematicInference <Component = A >>>,
340
+ update : Option <Box <dyn SchematicUpdate <Component = A >>>,
341
+ }
342
+ ```
343
+ * ` UntypedSchematic ` is
344
+ ``` rust
345
+ struct UntypedSchematic {
346
+ conversion : Vec <Box <dyn SchematicConversion >>,
347
+ inference : Vec <Box <dyn SchematicInference >>,
348
+ update : Vec <Box <dyn SchematicUpdate >>,
311
349
}
312
350
```
313
351
* ` SchematicConversion ` , ` SchematicInference ` and ` SchematicUpdate ` are basically just ` System ` with a restriction on the parameters
0 commit comments