bevy/crates/bevy_ecs/src
Jakob Hellermann 218b0fd3b6 bevy_reflect: put serialize into external ReflectSerialize type (#4782)
builds on top of #4780 

# Objective

`Reflect` and `Serialize` are currently very tied together because `Reflect` has a `fn serialize(&self) -> Option<Serializable<'_>>` method. Because of that, we can either implement `Reflect` for types like `Option<T>` with `T: Serialize` and have `fn serialize` be implemented, or without the bound but having `fn serialize` return `None`.

By separating `ReflectSerialize` into a separate type (like how it already is for `ReflectDeserialize`, `ReflectDefault`), we could separately `.register::<Option<T>>()` and `.register_data::<Option<T>, ReflectSerialize>()` only if the type `T: Serialize`.

This PR does not change the registration but allows it to be changed in a future PR.

## Solution

- add the type
```rust
struct ReflectSerialize { .. }
impl<T: Reflect + Serialize> FromType<T> for ReflectSerialize { .. }
```

- remove `#[reflect(Serialize)]` special casing. 

- when serializing reflect value types, look for `ReflectSerialize` in the `TypeRegistry` instead of calling `value.serialize()`
2022-06-20 17:18:58 +00:00
..
entity Implement FusedIterator for eligible Iterator types (#4942) 2022-06-09 03:19:31 +00:00
query Replace ReadOnlyFetch with ReadOnlyWorldQuery (#4626) 2022-06-13 23:35:54 +00:00
schedule Bugfix State::set transition condition infinite loop (#4890) 2022-06-12 19:34:26 +00:00
storage Replace ComponentSparseSet's internals with a Column (#4909) 2022-06-09 03:34:51 +00:00
system Replace ReadOnlyFetch with ReadOnlyWorldQuery (#4626) 2022-06-13 23:35:54 +00:00
world Fix broken WorldCell test (#5009) 2022-06-14 16:14:33 +00:00
archetype.rs Change Cow<[ComponentId]> to Box<[ComponentId]> (#4185) 2022-03-19 04:14:27 +00:00
bundle.rs Add comparison methods to FilteredAccessSet (#4211) 2022-05-09 14:39:22 +00:00
change_detection.rs untyped APIs for components and resources (#4447) 2022-05-30 15:32:47 +00:00
component.rs Clippy improvements (#4665) 2022-05-31 01:38:07 +00:00
event.rs Add a clear() method to the EventReader that consumes the iterator (#4693) 2022-05-13 00:57:04 +00:00
lib.rs Add global init and get accessors for all newtyped TaskPools (#2250) 2022-06-09 02:43:24 +00:00
reflect.rs bevy_reflect: put serialize into external ReflectSerialize type (#4782) 2022-06-20 17:18:58 +00:00