rfcs icon indicating copy to clipboard operation
rfcs copied to clipboard

bevy_reflect: Unique `Reflect`

Open nicopap opened this issue 3 years ago • 3 comments

RENDERED

  • create a new trait: PartialReflect
  • Reflect: PartialReflect
  • All methods on Reflect that does not depend on the uniqueness of the underlying type are moved to PartialReflect
  • Most things should now accept a dyn PartialReflect rather than dyn Reflect.
  • It is possible to convert a PartialReflect into a Reflect using a into_full method.
  • FromReflect becomes FromPartialReflect.

Unresolved questions

  • [X] CanonReflect name? ⇒ Went with Reflect and PartialReflect
  • [X] CanonReflect or ReflectProxy? Remove all underlying-dependent methods from Reflect and adding them to a new trait, or keep the underlying-dependent methods but moved all the non-dependent methods to a new trait. Which one to go with? ⇒ Went with a bit of both.
  • [X] Implementation (partial: https://github.com/bevyengine/bevy/pull/7207)
  • [ ] Consider making more things Reflect.
  • [X] Is a TypeRegistry entry for FromPartialReflect necessary? (no, as per partial implementation)

nicopap avatar May 20 '22 06:05 nicopap

palliate

@nicopap could you clarify this by using a simpler word than “palliate”?

colepoirier avatar Jun 05 '22 19:06 colepoirier

Next revision:

  • CanonReflect, ReflectReflect, PartialReflect
  • add into_canon to PartialReflect
  • Remove FromReflect change (though it will be renamed FromPartialReflect)

nicopap avatar Jun 19 '22 06:06 nicopap

Nice! Just wanted to note that another advantage of using PartialReflect is that it will be possible to optimize the serde format by not serializing default values.

This will be very useful for scenes and networking

afonsolage avatar Sep 10 '22 22:09 afonsolage