Struct bevy_ecs::reflect::ReflectResourceFns
source · pub struct ReflectResourceFns {
pub insert: fn(_: &mut World, _: &dyn Reflect),
pub apply: fn(_: &mut World, _: &dyn Reflect),
pub apply_or_insert: fn(_: &mut World, _: &dyn Reflect),
pub remove: fn(_: &mut World),
pub reflect: fn(_: &World) -> Option<&dyn Reflect>,
pub reflect_unchecked_mut: unsafe fn(_: UnsafeWorldCell<'_>) -> Option<Mut<'_, dyn Reflect>>,
pub copy: fn(_: &World, _: &mut World),
}
Expand description
The raw function pointers needed to make up a ReflectResource
.
This is used when creating custom implementations of ReflectResource
with
ReflectResource::new()
.
Note: Creating custom implementations of
ReflectResource
is an advanced feature that most users will not need. Usually aReflectResource
is created for a type by derivingReflect
and adding the#[reflect(Resource)]
attribute. After adding the component to theTypeRegistry
, itsReflectResource
can then be retrieved when needed.
Creating a custom ReflectResource
may be useful if you need to create new resource types at
runtime, for example, for scripting implementations.
By creating a custom ReflectResource
and inserting it into a type’s
TypeRegistration
,
you can modify the way that reflected resources of that type will be inserted into the bevy
world.
Fields§
§insert: fn(_: &mut World, _: &dyn Reflect)
Function pointer implementing ReflectResource::insert()
.
apply: fn(_: &mut World, _: &dyn Reflect)
Function pointer implementing ReflectResource::apply()
.
apply_or_insert: fn(_: &mut World, _: &dyn Reflect)
Function pointer implementing ReflectResource::apply_or_insert()
.
remove: fn(_: &mut World)
Function pointer implementing ReflectResource::remove()
.
reflect: fn(_: &World) -> Option<&dyn Reflect>
Function pointer implementing ReflectResource::reflect()
.
reflect_unchecked_mut: unsafe fn(_: UnsafeWorldCell<'_>) -> Option<Mut<'_, dyn Reflect>>
Function pointer implementing ReflectResource::reflect_unchecked_mut()
.
Safety
The function may only be called with an UnsafeWorldCell
that can be used to mutably access the relevant resource.
copy: fn(_: &World, _: &mut World)
Function pointer implementing ReflectResource::copy()
.
Implementations§
source§impl ReflectResourceFns
impl ReflectResourceFns
sourcepub fn new<T: Resource + Reflect + FromWorld>() -> Self
pub fn new<T: Resource + Reflect + FromWorld>() -> Self
Get the default set of ReflectResourceFns
for a specific resource type using its
FromType
implementation.
This is useful if you want to start with the default implementation before overriding some of the functions to create a custom implementation.
Trait Implementations§
source§impl Clone for ReflectResourceFns
impl Clone for ReflectResourceFns
source§fn clone(&self) -> ReflectResourceFns
fn clone(&self) -> ReflectResourceFns
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl RefUnwindSafe for ReflectResourceFns
impl Send for ReflectResourceFns
impl Sync for ReflectResourceFns
impl Unpin for ReflectResourceFns
impl UnwindSafe for ReflectResourceFns
Blanket Implementations§
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
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>
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>
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)
&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)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.