Struct bevy_reflect::TypeRegistration
source · pub struct TypeRegistration { /* private fields */ }
Expand description
A record of data about a type.
This contains the TypeInfo
of the type, as well as its short name.
For each trait specified by the #[reflect(_)]
attribute of
#[derive(Reflect)]
on the registered type, this record also contains
a TypeData
which can be used to downcast Reflect
trait objects of
this type to trait objects of the relevant trait.
Implementations§
source§impl TypeRegistration
impl TypeRegistration
sourcepub fn data<T: TypeData>(&self) -> Option<&T>
pub fn data<T: TypeData>(&self) -> Option<&T>
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: TypeData>(&mut self) -> Option<&mut T>
pub fn data_mut<T: TypeData>(&mut self) -> Option<&mut T>
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
sourcepub fn insert<T: TypeData>(&mut self, data: T)
pub fn insert<T: TypeData>(&mut self, data: T)
Inserts an instance of T
into this registration’s type data.
If another instance of T
was previously inserted, it is replaced.
sourcepub fn short_name(&self) -> &str
pub fn short_name(&self) -> &str
Returns the short name of the type.
Trait Implementations§
source§impl Clone for TypeRegistration
impl Clone for TypeRegistration
Auto 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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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
. Read moresource§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read moresource§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read moresource§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more