What problem does this solve or what need does it fill?
bevy_reflect uses TypeRegistry to keep track of metadata used to dynamic interact with Reflect types. This is also used by ser/de operations, like bevy_scene and any networking.
Users should keep a reference to a single TypeRegistry that contains all types registered and pass it around to Scenes, ReflectSerializer, *ReflectDeserializer and any type which needs to deal with its metadata, which is very verbose to carry around.
Also this make it hard to have custom ReflectSerialize and ReflectDeserialize implementations, since there is no TypeRegistry available, where in this case, users should make the TypeRegistry global available themselves.
Usually the TypeRegistry is written once, at the App startup, either by plugins or by any custom logic, and then read by any bevy_reflect operations which needs to know it's metadata.
What solution would you like?
Add a default global available TypeRegistry, to be used when a single TypeRegistry is required (which should cover most use cases), but keep TypeRegistry to be instantiated and be used individually when required (something like ReflectSerializer::with_registry).
- Make
TypeRegistry global available;
- Change
ReflectSerializer/*ReflectDeserializer; to use global TypeRegistry by default;
- Add an option to use a custom
TypeRegistry on:
ReflectSerializer;
*ReflectDeserializer;
What alternative(s) have you considered?
Let users create a global available TypeRegistry, to be built after app startup and use it. This will solve the problem of accessing TypeRegistry inside a custom ReflectSerialize/ReflectDeserialize but keeping the verbosity of carrying around the TypeRegistry.
Additional context
I'll do some researches on this subject, but there are some questions which needs to be solved, mostly to know how far should we go with this enhancement:
Also, another questions to be answered:
What problem does this solve or what need does it fill?
bevy_reflectusesTypeRegistryto keep track of metadata used to dynamic interact withReflecttypes. This is also used by ser/de operations, likebevy_sceneand any networking.Users should keep a reference to a single
TypeRegistrythat contains all types registered and pass it around toScenes,ReflectSerializer,*ReflectDeserializerand any type which needs to deal with its metadata, which is very verbose to carry around.Also this make it hard to have custom
ReflectSerializeandReflectDeserializeimplementations, since there is noTypeRegistryavailable, where in this case, users should make theTypeRegistryglobal available themselves.Usually the
TypeRegistryis written once, at theAppstartup, either by plugins or by any custom logic, and then read by anybevy_reflectoperations which needs to know it's metadata.What solution would you like?
Add a default global available
TypeRegistry, to be used when a singleTypeRegistryis required (which should cover most use cases), but keepTypeRegistryto be instantiated and be used individually when required (something likeReflectSerializer::with_registry).TypeRegistryglobal available;ReflectSerializer/*ReflectDeserializer; to use globalTypeRegistryby default;TypeRegistryon:ReflectSerializer;*ReflectDeserializer;What alternative(s) have you considered?
Let users create a global available
TypeRegistry, to be built after app startup and use it. This will solve the problem of accessingTypeRegistryinside a customReflectSerialize/ReflectDeserializebut keeping the verbosity of carrying around theTypeRegistry.Additional context
I'll do some researches on this subject, but there are some questions which needs to be solved, mostly to know how far should we go with this enhancement:
DynamicSceneto also use globalTypeRegistryby default?App::register_typein favor of a staticTypeRegistry::register_type?TypeRegistryfromApp?Also, another questions to be answered:
TypeRegistryshould be kept around?