Struct bevy::reflect::TypeRegistration
source · pub struct TypeRegistration { /* private fields */ }
Expand description
Runtime storage for type metadata, registered into the TypeRegistry
.
An instance of TypeRegistration
can be created using the TypeRegistration::of
method,
but is more often automatically generated using #[derive(Reflect)]
which itself generates
an implementation of the GetTypeRegistration
trait.
Along with the type’s TypeInfo
,
this struct also contains a type’s registered TypeData
.
See the crate-level documentation for more information on type registration.
Example
let mut registration = TypeRegistration::of::<Option<String>>();
assert_eq!("core::option::Option<alloc::string::String>", registration.type_info().type_path());
assert_eq!("Option<String>", registration.type_info().type_path_table().short_path());
registration.insert::<ReflectDefault>(FromType::<Option<String>>::from_type());
assert!(registration.data::<ReflectDefault>().is_some())
Implementations§
source§impl TypeRegistration
impl TypeRegistration
sourcepub fn data<T>(&self) -> Option<&T>where
T: TypeData,
pub fn data<T>(&self) -> Option<&T>where
T: TypeData,
Returns a reference to the value of type T
in this registration’s type
data.
Returns None
if no such value exists.
sourcepub fn data_mut<T>(&mut self) -> Option<&mut T>where
T: TypeData,
pub fn data_mut<T>(&mut self) -> Option<&mut T>where
T: TypeData,
Returns a mutable reference to the value of type T
in this
registration’s type data.
Returns None
if no such value exists.
sourcepub fn type_info(&self) -> &'static TypeInfo
pub fn type_info(&self) -> &'static TypeInfo
Returns a reference to the registration’s TypeInfo
Trait Implementations§
source§impl Clone for TypeRegistration
impl Clone for TypeRegistration
source§fn clone(&self) -> TypeRegistration
fn clone(&self) -> TypeRegistration
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for TypeRegistration
impl Send for TypeRegistration
impl Sync for TypeRegistration
impl Unpin for TypeRegistration
impl !UnwindSafe for TypeRegistration
Blanket Implementations§
source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
Return the
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.