pub trait DynamicBundle: Sized {
type Effect;
// Required methods
unsafe fn get_components(
ptr: MovingPtr<'_, Self>,
func: &mut impl FnMut(StorageType, OwningPtr<'_>),
);
unsafe fn apply_effect(
ptr: MovingPtr<'_, MaybeUninit<Self>>,
entity: &mut EntityWorldMut<'_>,
);
}Expand description
The parts from Bundle that don’t require statically knowing the components of the bundle.
Required Associated Types§
Required Methods§
Sourceunsafe fn get_components(
ptr: MovingPtr<'_, Self>,
func: &mut impl FnMut(StorageType, OwningPtr<'_>),
)
unsafe fn get_components( ptr: MovingPtr<'_, Self>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), )
Moves the components out of the bundle.
§Safety
For callers:
- Must be called exactly once before
apply_effect - The
StorageTypeargument passed intofuncmust be correct for the component being fetched. apply_effectmust be called exactly once after this has been called ifEffect: !NoBundleEffect
For implementors:
- Implementors of this function must convert
ptrinto pointers to individual components stored withinSelfand callfuncon each of them in exactly the same order asBundle::get_component_idsandBundleFromComponents::from_components. - If any part of
ptris to be accessed inapply_effect, it must not be dropped at any point in this function. Callingbevy_ptr::deconstruct_moving_ptrin this function automatically ensures this.
Sourceunsafe fn apply_effect(
ptr: MovingPtr<'_, MaybeUninit<Self>>,
entity: &mut EntityWorldMut<'_>,
)
unsafe fn apply_effect( ptr: MovingPtr<'_, MaybeUninit<Self>>, entity: &mut EntityWorldMut<'_>, )
Applies the after-effects of spawning this bundle.
This is applied after all residual changes to the World, including flushing the internal command
queue.
§Safety
For callers:
- Must be called exactly once after
get_componentshas been called. ptrmust point to the instance ofSelfthatget_componentswas called on, all of fields that were moved out of inget_componentswill not be valid anymore.
For implementors:
- If any part of
ptris to be accessed in this function, it must not be dropped at any point inget_components. Callingbevy_ptr::deconstruct_moving_ptringet_componentsautomatically ensures this is the case.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.