use crate::{1array_debug, enum_debug, list_debug, map_debug, set_debug, struct_debug, tuple_debug,2tuple_struct_debug, DynamicTypePath, DynamicTyped, OpaqueInfo, ReflectCloneError, ReflectKind,3ReflectKindMismatchError, ReflectMut, ReflectOwned, ReflectRef, TypeInfo, TypePath, Typed,4};5use alloc::borrow::Cow;6use alloc::boxed::Box;7use alloc::string::ToString;8use core::{9any::{Any, TypeId},10fmt::Debug,11};1213use thiserror::Error;1415use crate::utility::NonGenericTypeInfoCell;1617/// A enumeration of all error outcomes that might happen when running [`try_apply`](PartialReflect::try_apply).18#[derive(Error, Debug)]19pub enum ApplyError {20#[error("attempted to apply `{from_kind}` to `{to_kind}`")]21/// Attempted to apply the wrong [kind](ReflectKind) to a type, e.g. a struct to an enum.22MismatchedKinds {23/// Kind of the value we attempted to apply.24from_kind: ReflectKind,25/// Kind of the type we attempted to apply the value to.26to_kind: ReflectKind,27},2829#[error("enum variant `{variant_name}` doesn't have a field named `{field_name}`")]30/// Enum variant that we tried to apply to was missing a field.31MissingEnumField {32/// Name of the enum variant.33variant_name: Box<str>,34/// Name of the missing field.35field_name: Box<str>,36},3738#[error("`{from_type}` is not `{to_type}`")]39/// Tried to apply incompatible types.40MismatchedTypes {41/// Type of the value we attempted to apply.42from_type: Box<str>,43/// Type we attempted to apply the value to.44to_type: Box<str>,45},4647#[error("attempted to apply type with {from_size} size to a type with {to_size} size")]48/// Attempted to apply an [array-like] type to another of different size, e.g. a [u8; 4] to [u8; 3].49///50/// [array-like]: crate::Array51DifferentSize {52/// Size of the value we attempted to apply, in elements.53from_size: usize,54/// Size of the type we attempted to apply the value to, in elements.55to_size: usize,56},5758#[error("variant with name `{variant_name}` does not exist on enum `{enum_name}`")]59/// The enum we tried to apply to didn't contain a variant with the give name.60UnknownVariant {61/// Name of the enum.62enum_name: Box<str>,63/// Name of the missing variant.64variant_name: Box<str>,65},66}6768impl From<ReflectKindMismatchError> for ApplyError {69fn from(value: ReflectKindMismatchError) -> Self {70Self::MismatchedKinds {71from_kind: value.received,72to_kind: value.expected,73}74}75}7677/// The foundational trait of [`bevy_reflect`], used for accessing and modifying data dynamically.78///79/// This is a supertrait of [`Reflect`],80/// meaning any type which implements `Reflect` implements `PartialReflect` by definition.81///82/// It's recommended to use [the derive macro for `Reflect`] rather than manually implementing this trait.83/// Doing so will automatically implement this trait as well as many other useful traits for reflection,84/// including one of the appropriate subtraits: [`Struct`], [`TupleStruct`] or [`Enum`].85///86/// See the [crate-level documentation] to see how this trait and its subtraits can be used.87///88/// [`bevy_reflect`]: crate89/// [the derive macro for `Reflect`]: bevy_reflect_derive::Reflect90/// [`Struct`]: crate::Struct91/// [`TupleStruct`]: crate::TupleStruct92/// [`Enum`]: crate::Enum93/// [crate-level documentation]: crate94#[diagnostic::on_unimplemented(95message = "`{Self}` does not implement `PartialReflect` so cannot be introspected",96note = "consider annotating `{Self}` with `#[derive(Reflect)]`"97)]98pub trait PartialReflect: DynamicTypePath + Send + Sync99where100// NB: we don't use `Self: Any` since for downcasting, `Reflect` should be used.101Self: 'static,102{103/// Returns the [`TypeInfo`] of the type _represented_ by this value.104///105/// For most types, this will simply return their own `TypeInfo`.106/// However, for dynamic types, such as [`DynamicStruct`] or [`DynamicList`],107/// this will return the type they represent108/// (or `None` if they don't represent any particular type).109///110/// This method is great if you have an instance of a type or a `dyn Reflect`,111/// and want to access its [`TypeInfo`]. However, if this method is to be called112/// frequently, consider using [`TypeRegistry::get_type_info`] as it can be more113/// performant for such use cases.114///115/// [`DynamicStruct`]: crate::DynamicStruct116/// [`DynamicList`]: crate::DynamicList117/// [`TypeRegistry::get_type_info`]: crate::TypeRegistry::get_type_info118fn get_represented_type_info(&self) -> Option<&'static TypeInfo>;119120/// Casts this type to a boxed, reflected value.121///122/// This is useful for coercing trait objects.123fn into_partial_reflect(self: Box<Self>) -> Box<dyn PartialReflect>;124125/// Casts this type to a reflected value.126///127/// This is useful for coercing trait objects.128fn as_partial_reflect(&self) -> &dyn PartialReflect;129130/// Casts this type to a mutable, reflected value.131///132/// This is useful for coercing trait objects.133fn as_partial_reflect_mut(&mut self) -> &mut dyn PartialReflect;134135/// Attempts to cast this type to a boxed, [fully-reflected] value.136///137/// [fully-reflected]: Reflect138fn try_into_reflect(self: Box<Self>) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>;139140/// Attempts to cast this type to a [fully-reflected] value.141///142/// [fully-reflected]: Reflect143fn try_as_reflect(&self) -> Option<&dyn Reflect>;144145/// Attempts to cast this type to a mutable, [fully-reflected] value.146///147/// [fully-reflected]: Reflect148fn try_as_reflect_mut(&mut self) -> Option<&mut dyn Reflect>;149150/// Applies a reflected value to this value.151///152/// If `Self` implements a [reflection subtrait], then the semantics of this153/// method are as follows:154/// - If `Self` is a [`Struct`], then the value of each named field of `value` is155/// applied to the corresponding named field of `self`. Fields which are156/// not present in both structs are ignored.157/// - If `Self` is a [`TupleStruct`] or [`Tuple`], then the value of each158/// numbered field is applied to the corresponding numbered field of159/// `self.` Fields which are not present in both values are ignored.160/// - If `Self` is an [`Enum`], then the variant of `self` is `updated` to match161/// the variant of `value`. The corresponding fields of that variant are162/// applied from `value` onto `self`. Fields which are not present in both163/// values are ignored.164/// - If `Self` is a [`List`] or [`Array`], then each element of `value` is applied165/// to the corresponding element of `self`. Up to `self.len()` items are applied,166/// and excess elements in `value` are appended to `self`.167/// - If `Self` is a [`Map`], then for each key in `value`, the associated168/// value is applied to the value associated with the same key in `self`.169/// Keys which are not present in `self` are inserted, and keys from `self` which are not present in `value` are removed.170/// - If `Self` is a [`Set`], then each element of `value` is applied to the corresponding171/// element of `Self`. If an element of `value` does not exist in `Self` then it is172/// cloned and inserted. If an element from `self` is not present in `value` then it is removed.173/// - If `Self` is none of these, then `value` is downcast to `Self`, cloned, and174/// assigned to `self`.175///176/// Note that `Reflect` must be implemented manually for [`List`]s,177/// [`Map`]s, and [`Set`]s in order to achieve the correct semantics, as derived178/// implementations will have the semantics for [`Struct`], [`TupleStruct`], [`Enum`]179/// or none of the above depending on the kind of type. For lists, maps, and sets, use the180/// [`list_apply`], [`map_apply`], and [`set_apply`] helper functions when implementing this method.181///182/// [reflection subtrait]: crate#the-reflection-subtraits183/// [`Struct`]: crate::Struct184/// [`TupleStruct`]: crate::TupleStruct185/// [`Tuple`]: crate::Tuple186/// [`Enum`]: crate::Enum187/// [`List`]: crate::List188/// [`Array`]: crate::Array189/// [`Map`]: crate::Map190/// [`Set`]: crate::Set191/// [`list_apply`]: crate::list_apply192/// [`map_apply`]: crate::map_apply193/// [`set_apply`]: crate::set_apply194///195/// # Panics196///197/// Derived implementations of this method will panic:198/// - If the type of `value` is not of the same kind as `Self` (e.g. if `Self` is199/// a `List`, while `value` is a `Struct`).200/// - If `Self` is any complex type and the corresponding fields or elements of201/// `self` and `value` are not of the same type.202/// - If `Self` is an opaque type and `value` cannot be downcast to `Self`203fn apply(&mut self, value: &dyn PartialReflect) {204PartialReflect::try_apply(self, value).unwrap();205}206207/// Tries to [`apply`](PartialReflect::apply) a reflected value to this value.208///209/// Functions the same as the [`apply`](PartialReflect::apply) function but returns an error instead of210/// panicking.211///212/// # Handling Errors213///214/// This function may leave `self` in a partially mutated state if a error was encountered on the way.215/// consider maintaining a cloned instance of this data you can switch to if a error is encountered.216fn try_apply(&mut self, value: &dyn PartialReflect) -> Result<(), ApplyError>;217218/// Returns a zero-sized enumeration of "kinds" of type.219///220/// See [`ReflectKind`].221fn reflect_kind(&self) -> ReflectKind {222self.reflect_ref().kind()223}224225/// Returns an immutable enumeration of "kinds" of type.226///227/// See [`ReflectRef`].228fn reflect_ref(&self) -> ReflectRef<'_>;229230/// Returns a mutable enumeration of "kinds" of type.231///232/// See [`ReflectMut`].233fn reflect_mut(&mut self) -> ReflectMut<'_>;234235/// Returns an owned enumeration of "kinds" of type.236///237/// See [`ReflectOwned`].238fn reflect_owned(self: Box<Self>) -> ReflectOwned;239240/// Converts this reflected value into its dynamic representation based on its [kind].241///242/// For example, a [`List`] type will internally invoke [`List::to_dynamic_list`], returning [`DynamicList`].243/// A [`Struct`] type will invoke [`Struct::to_dynamic_struct`], returning [`DynamicStruct`].244/// And so on.245///246/// If the [kind] is [opaque], then the value will attempt to be cloned directly via [`reflect_clone`],247/// since opaque types do not have any standard dynamic representation.248///249/// To attempt to clone the value directly such that it returns a concrete instance of this type,250/// use [`reflect_clone`].251///252/// # Panics253///254/// This method will panic if the [kind] is [opaque] and the call to [`reflect_clone`] fails.255///256/// # Example257///258/// ```259/// # use bevy_reflect::{PartialReflect};260/// let value = (1, true, 3.14);261/// let dynamic_value = value.to_dynamic();262/// assert!(dynamic_value.is_dynamic())263/// ```264///265/// [kind]: PartialReflect::reflect_kind266/// [`List`]: crate::List267/// [`List::to_dynamic_list`]: crate::List::to_dynamic_list268/// [`DynamicList`]: crate::DynamicList269/// [`Struct`]: crate::Struct270/// [`Struct::to_dynamic_struct`]: crate::Struct::to_dynamic_struct271/// [`DynamicStruct`]: crate::DynamicStruct272/// [opaque]: crate::ReflectKind::Opaque273/// [`reflect_clone`]: PartialReflect::reflect_clone274fn to_dynamic(&self) -> Box<dyn PartialReflect> {275match self.reflect_ref() {276ReflectRef::Struct(dyn_struct) => Box::new(dyn_struct.to_dynamic_struct()),277ReflectRef::TupleStruct(dyn_tuple_struct) => {278Box::new(dyn_tuple_struct.to_dynamic_tuple_struct())279}280ReflectRef::Tuple(dyn_tuple) => Box::new(dyn_tuple.to_dynamic_tuple()),281ReflectRef::List(dyn_list) => Box::new(dyn_list.to_dynamic_list()),282ReflectRef::Array(dyn_array) => Box::new(dyn_array.to_dynamic_array()),283ReflectRef::Map(dyn_map) => Box::new(dyn_map.to_dynamic_map()),284ReflectRef::Set(dyn_set) => Box::new(dyn_set.to_dynamic_set()),285ReflectRef::Enum(dyn_enum) => Box::new(dyn_enum.to_dynamic_enum()),286#[cfg(feature = "functions")]287ReflectRef::Function(dyn_function) => Box::new(dyn_function.to_dynamic_function()),288ReflectRef::Opaque(value) => value.reflect_clone().unwrap().into_partial_reflect(),289}290}291292/// Attempts to clone `Self` using reflection.293///294/// Unlike [`to_dynamic`], which generally returns a dynamic representation of `Self`,295/// this method attempts create a clone of `Self` directly, if possible.296///297/// If the clone cannot be performed, an appropriate [`ReflectCloneError`] is returned.298///299/// # Example300///301/// ```302/// # use bevy_reflect::PartialReflect;303/// let value = (1, true, 3.14);304/// let cloned = value.reflect_clone().unwrap();305/// assert!(cloned.is::<(i32, bool, f64)>())306/// ```307///308/// [`to_dynamic`]: PartialReflect::to_dynamic309fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError> {310Err(ReflectCloneError::NotImplemented {311type_path: Cow::Owned(self.reflect_type_path().to_string()),312})313}314315/// For a type implementing [`PartialReflect`], combines `reflect_clone` and316/// `take` in a useful fashion, automatically constructing an appropriate317/// [`ReflectCloneError`] if the downcast fails.318///319/// This is an associated function, rather than a method, because methods320/// with generic types prevent dyn-compatibility.321fn reflect_clone_and_take<T: 'static>(&self) -> Result<T, ReflectCloneError>322where323Self: TypePath + Sized,324{325self.reflect_clone()?326.take()327.map_err(|_| ReflectCloneError::FailedDowncast {328expected: Cow::Borrowed(<Self as TypePath>::type_path()),329received: Cow::Owned(self.reflect_type_path().to_string()),330})331}332333/// Returns a hash of the value (which includes the type).334///335/// If the underlying type does not support hashing, returns `None`.336fn reflect_hash(&self) -> Option<u64> {337None338}339340/// Returns a "partial equality" comparison result.341///342/// If the underlying type does not support equality testing, returns `None`.343fn reflect_partial_eq(&self, _value: &dyn PartialReflect) -> Option<bool> {344None345}346347/// Debug formatter for the value.348///349/// Any value that is not an implementor of other `Reflect` subtraits350/// (e.g. [`List`], [`Map`]), will default to the format: `"Reflect(type_path)"`,351/// where `type_path` is the [type path] of the underlying type.352///353/// [`List`]: crate::List354/// [`Map`]: crate::Map355/// [type path]: TypePath::type_path356fn debug(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {357match self.reflect_ref() {358ReflectRef::Struct(dyn_struct) => struct_debug(dyn_struct, f),359ReflectRef::TupleStruct(dyn_tuple_struct) => tuple_struct_debug(dyn_tuple_struct, f),360ReflectRef::Tuple(dyn_tuple) => tuple_debug(dyn_tuple, f),361ReflectRef::List(dyn_list) => list_debug(dyn_list, f),362ReflectRef::Array(dyn_array) => array_debug(dyn_array, f),363ReflectRef::Map(dyn_map) => map_debug(dyn_map, f),364ReflectRef::Set(dyn_set) => set_debug(dyn_set, f),365ReflectRef::Enum(dyn_enum) => enum_debug(dyn_enum, f),366#[cfg(feature = "functions")]367ReflectRef::Function(dyn_function) => dyn_function.fmt(f),368ReflectRef::Opaque(_) => write!(f, "Reflect({})", self.reflect_type_path()),369}370}371372/// Indicates whether or not this type is a _dynamic_ type.373///374/// Dynamic types include the ones built-in to this [crate],375/// such as [`DynamicStruct`], [`DynamicList`], and [`DynamicTuple`].376/// However, they may be custom types used as proxies for other types377/// or to facilitate scripting capabilities.378///379/// By default, this method will return `false`.380///381/// [`DynamicStruct`]: crate::DynamicStruct382/// [`DynamicList`]: crate::DynamicList383/// [`DynamicTuple`]: crate::DynamicTuple384fn is_dynamic(&self) -> bool {385false386}387}388389/// A core trait of [`bevy_reflect`], used for downcasting to concrete types.390///391/// This is a subtrait of [`PartialReflect`],392/// meaning any type which implements `Reflect` implements `PartialReflect` by definition.393///394/// It's recommended to use [the derive macro] rather than manually implementing this trait.395/// Doing so will automatically implement this trait, [`PartialReflect`], and many other useful traits for reflection,396/// including one of the appropriate subtraits: [`Struct`], [`TupleStruct`] or [`Enum`].397///398/// If you need to use this trait as a generic bound along with other reflection traits,399/// for your convenience, consider using [`Reflectable`] instead.400///401/// See the [crate-level documentation] to see how this trait can be used.402///403/// [`bevy_reflect`]: crate404/// [the derive macro]: bevy_reflect_derive::Reflect405/// [`Struct`]: crate::Struct406/// [`TupleStruct`]: crate::TupleStruct407/// [`Enum`]: crate::Enum408/// [`Reflectable`]: crate::Reflectable409/// [crate-level documentation]: crate410#[diagnostic::on_unimplemented(411message = "`{Self}` does not implement `Reflect` so cannot be fully reflected",412note = "consider annotating `{Self}` with `#[derive(Reflect)]`"413)]414pub trait Reflect: PartialReflect + DynamicTyped + Any {415/// Returns the value as a [`Box<dyn Any>`][core::any::Any].416///417/// For remote wrapper types, this will return the remote type instead.418fn into_any(self: Box<Self>) -> Box<dyn Any>;419420/// Returns the value as a [`&dyn Any`][core::any::Any].421///422/// For remote wrapper types, this will return the remote type instead.423fn as_any(&self) -> &dyn Any;424425/// Returns the value as a [`&mut dyn Any`][core::any::Any].426///427/// For remote wrapper types, this will return the remote type instead.428fn as_any_mut(&mut self) -> &mut dyn Any;429430/// Casts this type to a boxed, fully-reflected value.431fn into_reflect(self: Box<Self>) -> Box<dyn Reflect>;432433/// Casts this type to a fully-reflected value.434fn as_reflect(&self) -> &dyn Reflect;435436/// Casts this type to a mutable, fully-reflected value.437fn as_reflect_mut(&mut self) -> &mut dyn Reflect;438439/// Performs a type-checked assignment of a reflected value to this value.440///441/// If `value` does not contain a value of type `T`, returns an `Err`442/// containing the trait object.443fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>;444}445446impl dyn PartialReflect {447/// Returns `true` if the underlying value represents a value of type `T`, or `false`448/// otherwise.449///450/// Read `is` for more information on underlying values and represented types.451#[inline]452pub fn represents<T: Reflect + TypePath>(&self) -> bool {453self.get_represented_type_info()454.is_some_and(|t| t.type_path() == T::type_path())455}456457/// Downcasts the value to type `T`, consuming the trait object.458///459/// If the underlying value does not implement [`Reflect`]460/// or is not of type `T`, returns `Err(self)`.461///462/// For remote types, `T` should be the type itself rather than the wrapper type.463pub fn try_downcast<T: Any>(464self: Box<dyn PartialReflect>,465) -> Result<Box<T>, Box<dyn PartialReflect>> {466self.try_into_reflect()?467.downcast()468.map_err(PartialReflect::into_partial_reflect)469}470471/// Downcasts the value to type `T`, unboxing and consuming the trait object.472///473/// If the underlying value does not implement [`Reflect`]474/// or is not of type `T`, returns `Err(self)`.475///476/// For remote types, `T` should be the type itself rather than the wrapper type.477pub fn try_take<T: Any>(self: Box<dyn PartialReflect>) -> Result<T, Box<dyn PartialReflect>> {478self.try_downcast().map(|value| *value)479}480481/// Downcasts the value to type `T` by reference.482///483/// If the underlying value does not implement [`Reflect`]484/// or is not of type `T`, returns [`None`].485///486/// For remote types, `T` should be the type itself rather than the wrapper type.487pub fn try_downcast_ref<T: Any>(&self) -> Option<&T> {488self.try_as_reflect()?.downcast_ref()489}490491/// Downcasts the value to type `T` by mutable reference.492///493/// If the underlying value does not implement [`Reflect`]494/// or is not of type `T`, returns [`None`].495///496/// For remote types, `T` should be the type itself rather than the wrapper type.497pub fn try_downcast_mut<T: Any>(&mut self) -> Option<&mut T> {498self.try_as_reflect_mut()?.downcast_mut()499}500}501502impl Debug for dyn PartialReflect {503fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {504self.debug(f)505}506}507508// The following implementation never actually shadows the concrete TypePath implementation.509// See the comment on `dyn Reflect`'s `TypePath` implementation.510impl TypePath for dyn PartialReflect {511fn type_path() -> &'static str {512"dyn bevy_reflect::PartialReflect"513}514515fn short_type_path() -> &'static str {516"dyn PartialReflect"517}518}519520#[deny(rustdoc::broken_intra_doc_links)]521impl dyn Reflect {522/// Downcasts the value to type `T`, consuming the trait object.523///524/// If the underlying value is not of type `T`, returns `Err(self)`.525///526/// For remote types, `T` should be the type itself rather than the wrapper type.527pub fn downcast<T: Any>(self: Box<dyn Reflect>) -> Result<Box<T>, Box<dyn Reflect>> {528if self.is::<T>() {529Ok(self.into_any().downcast().unwrap())530} else {531Err(self)532}533}534535/// Downcasts the value to type `T`, unboxing and consuming the trait object.536///537/// If the underlying value is not of type `T`, returns `Err(self)`.538///539/// For remote types, `T` should be the type itself rather than the wrapper type.540pub fn take<T: Any>(self: Box<dyn Reflect>) -> Result<T, Box<dyn Reflect>> {541self.downcast::<T>().map(|value| *value)542}543544/// Returns `true` if the underlying value is of type `T`, or `false`545/// otherwise.546///547/// The underlying value is the concrete type that is stored in this `dyn` object;548/// it can be downcast to. In the case that this underlying value "represents"549/// a different type, like the Dynamic\*\*\* types do, you can call `represents`550/// to determine what type they represent. Represented types cannot be downcast551/// to, but you can use [`FromReflect`] to create a value of the represented type from them.552///553/// For remote types, `T` should be the type itself rather than the wrapper type.554///555/// [`FromReflect`]: crate::FromReflect556#[inline]557pub fn is<T: Any>(&self) -> bool {558self.as_any().type_id() == TypeId::of::<T>()559}560561/// Downcasts the value to type `T` by reference.562///563/// If the underlying value is not of type `T`, returns `None`.564///565/// For remote types, `T` should be the type itself rather than the wrapper type.566#[inline]567pub fn downcast_ref<T: Any>(&self) -> Option<&T> {568self.as_any().downcast_ref::<T>()569}570571/// Downcasts the value to type `T` by mutable reference.572///573/// If the underlying value is not of type `T`, returns `None`.574///575/// For remote types, `T` should be the type itself rather than the wrapper type.576#[inline]577pub fn downcast_mut<T: Any>(&mut self) -> Option<&mut T> {578self.as_any_mut().downcast_mut::<T>()579}580}581582impl Debug for dyn Reflect {583fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {584self.debug(f)585}586}587588impl Typed for dyn Reflect {589fn type_info() -> &'static TypeInfo {590static CELL: NonGenericTypeInfoCell = NonGenericTypeInfoCell::new();591CELL.get_or_set(|| TypeInfo::Opaque(OpaqueInfo::new::<Self>()))592}593}594595// The following implementation never actually shadows the concrete `TypePath` implementation.596// See this playground (https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=589064053f27bc100d90da89c6a860aa).597impl TypePath for dyn Reflect {598fn type_path() -> &'static str {599"dyn bevy_reflect::Reflect"600}601602fn short_type_path() -> &'static str {603"dyn Reflect"604}605}606607macro_rules! impl_full_reflect {608($(<$($id:ident),* $(,)?>)? for $ty:ty $(where $($tt:tt)*)?) => {609impl $(<$($id),*>)? $crate::Reflect for $ty $(where $($tt)*)? {610fn into_any(self: bevy_platform::prelude::Box<Self>) -> bevy_platform::prelude::Box<dyn ::core::any::Any> {611self612}613614fn as_any(&self) -> &dyn ::core::any::Any {615self616}617618fn as_any_mut(&mut self) -> &mut dyn ::core::any::Any {619self620}621622fn into_reflect(self: bevy_platform::prelude::Box<Self>) -> bevy_platform::prelude::Box<dyn $crate::Reflect> {623self624}625626fn as_reflect(&self) -> &dyn $crate::Reflect {627self628}629630fn as_reflect_mut(&mut self) -> &mut dyn $crate::Reflect {631self632}633634fn set(635&mut self,636value: bevy_platform::prelude::Box<dyn $crate::Reflect>,637) -> Result<(), bevy_platform::prelude::Box<dyn $crate::Reflect>> {638*self = <dyn $crate::Reflect>::take(value)?;639Ok(())640}641}642};643}644645pub(crate) use impl_full_reflect;646647648