Expand description
§Bevy Reflection on Steroids
A series of supplementary extensions to the
bevy_reflect
crate that powers aspects of the
Bevy game engine.
bevy_reflect
provides is a general reflection framework for Rust structs, with
rudimentary support for traits.
§Highlights
- Integrates seamlessly with
bevy_reflect
. - Includes a facility to register types globally without explicitly calling
TypeRegistry::register()
. This feature is gated behind the “inventory” crate feature, enabled by default. Seeenable_global_type_registration
. - Includes a facility to perform generic dynamic casts between trait objects,
patching a hole in the Rust language (similar to C++
dynamic_cast
). See theCast
trait. - Includes the equivalent of
downcast-rs
, but using theReflect
trait instead ofAny
. SeeDowncastReflect
. - Serialization and deserialization of opaque trait objects (similar to
typetag
).
This crate provides a much more intuitive and user-friendly way of interacting with reflected types through arbitrary trait objects.
By implementing DynamicTrait
for dyn MyTrait
, reflection is made available
to all dynamic trait object references of that type. The only requirements are
that the trait has DowncastReflect
as a supertrait, and that a call to the
macro impl_dynamic_trait!(MyTrait, ReflectMyTrait)
is
present in the code.
Re-exports§
pub use bevy_reflect as reflect;
Modules§
- prelude
- Prelude
- serialization
- Type-tagged serialization/deserialization utilities.
Macros§
- enable_
global_ type_ registration - Include a type in the global list of registered types.
- impl_
dynamic_ trait - Implement
DynamicTrait
for a trait object.
Enums§
- Type
Error - Type casting errors.
Traits§
- Cast
- Trait object casting interface.
- CastBox
- Box casting interface.
- CastMut
- Mutable reference casting interface.
- CastRef
- Reference casting interface.
- Downcast
Reflect - Similar to the
Downcast
trait from [::downcast-rs
], but using theReflect
trait instead ofstd::any::Any
. - Dynamic
Caster - Cast a reflected pointer to another trait object.
- Dynamic
Trait - Description of an interface. This is a way to associate trait object types
with some metadata that lives in the
TypeRegistry
. - Dynamic
Trait Ext - Convenience methods for all
DynamicTrait
implementations. - Type
Registry Ext - Extension methods for
TypeRegistry
.