mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
ba3d9b3fb6
# Objective The `ser` and `de` modules in `bevy_reflect/serde` are very long and difficult to navigate. ## Solution Refactor both modules into many smaller modules that each have a single primary focus (i.e. a `structs` module that only handles struct serialization/deserialization). I chose to keep the `ser` and `de` modules separate. We could have instead broken it up kind (e.g. lists, maps, etc.), but I think this is a little cleaner. Serialization and deserialization, while related, can be very different. So keeping them separated makes sense for organizational purposes. That being said, if people disagree and think we should structure this a different way, I am open to changing it. Note that this PR's changes are mainly structural. There are a few places I refactored code to reduce duplication and to make things a bit cleaner, but these are largely cosmetic and shouldn't have any impact on behavior. ### Other Details This PR also hides a lot of the internal logic from being exported. These were originally public, but it's unlikely they really saw any use outside of these modules. In fact, you don't really gain anything by using them outside of this module either. By privatizing these fields and items, we also set ourselves up for more easily changing internal logic around without involving a breaking change. I also chose not to mess around with tests since that would really blow up the diff haha. ## Testing You can test locally by running: ``` cargo test --package bevy_reflect --all-features ``` --- ## Migration Guide The fields on `ReflectSerializer` and `TypedReflectSerializer` are now private. To instantiate, the corresponding constructor must be used: ```rust // BEFORE let serializer = ReflectSerializer { value: &my_value, registry: &type_registry, }; // AFTER let serializer = ReflectSerializer::new(&my_value, &type_registry); ``` Additionally, the following types are no longer public: - `ArraySerializer` - `EnumSerializer` - `ListSerializer` - `MapSerializer` - `ReflectValueSerializer` (fully removed) - `StructSerializer` - `TupleSerializer` - `TupleStructSerializer` As well as the following traits: - `DeserializeValue` (fully removed) |
||
---|---|---|
.. | ||
bevy_a11y | ||
bevy_animation | ||
bevy_app | ||
bevy_asset | ||
bevy_audio | ||
bevy_color | ||
bevy_core | ||
bevy_core_pipeline | ||
bevy_derive | ||
bevy_dev_tools | ||
bevy_diagnostic | ||
bevy_dylib | ||
bevy_ecs | ||
bevy_encase_derive | ||
bevy_gilrs | ||
bevy_gizmos | ||
bevy_gltf | ||
bevy_hierarchy | ||
bevy_input | ||
bevy_internal | ||
bevy_log | ||
bevy_macro_utils | ||
bevy_math | ||
bevy_mikktspace | ||
bevy_pbr | ||
bevy_picking | ||
bevy_ptr | ||
bevy_reflect | ||
bevy_render | ||
bevy_scene | ||
bevy_sprite | ||
bevy_state | ||
bevy_tasks | ||
bevy_text | ||
bevy_time | ||
bevy_transform | ||
bevy_ui | ||
bevy_utils | ||
bevy_window | ||
bevy_winit |