bevy/crates
Gino Valente ba3d9b3fb6
bevy_reflect: Refactor serde module (#15107)
# 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)
2024-09-09 14:03:42 +00:00
..
bevy_a11y Add Reflect derive to bevy_a11y::Focus (#14763) 2024-08-15 17:33:20 +00:00
bevy_animation Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_app Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_asset Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_audio Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_color Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_core Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_core_pipeline Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_derive Remove deprecated bevy_dynamic_plugin (#14534) 2024-07-30 15:31:08 +00:00
bevy_dev_tools Remove all existing system order ambiguities in DefaultPlugins (#15031) 2024-09-03 20:24:34 +00:00
bevy_diagnostic Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00
bevy_dylib Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_ecs Fix error link (#15082) 2024-09-08 17:11:17 +00:00
bevy_encase_derive Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_gilrs Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_gizmos Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_gltf Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_hierarchy Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_input Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_internal Remove all existing system order ambiguities in DefaultPlugins (#15031) 2024-09-03 20:24:34 +00:00
bevy_log Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_macro_utils Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_math Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_mikktspace Fix underflow panic in InitTriInfo (#14893) 2024-08-25 14:13:23 +00:00
bevy_pbr More triangles/vertices per meshlet (#15023) 2024-09-08 17:55:57 +00:00
bevy_picking Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_ptr Migrated NonZero* to NonZero<*> (#14978) 2024-08-30 02:37:47 +00:00
bevy_reflect bevy_reflect: Refactor serde module (#15107) 2024-09-09 14:03:42 +00:00
bevy_render Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_scene Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_sprite Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_state Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_tasks Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_text Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_time Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_transform Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_ui Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_utils Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_window Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_winit Picking event ordering (#14862) 2024-09-04 19:41:06 +00:00