Struct DuplicationPlan

Source
pub struct DuplicationPlan<B: CloneBundle, const N: usize> { /* private fields */ }
Expand description

Owned snapshot of explicitly selected components for N distinct sources.

Created by World::plan_duplication. This holds no world borrow and never rereads sources, even after edits/despawns. Each component’s Clone defines whether its internal data stays shared (for example, an Rc<RefCell<_>>). Dropping the plan discards the clones. Stack storage/work scales with N and the selected bundle size; use small arrays for authoring. Clone may allocate. The plan is not a whole-world, identity, hierarchy or reference-remapping clone.

Implementations§

Source§

impl<B: CloneBundle, const N: usize> DuplicationPlan<B, N>

Source

pub fn try_spawn( self, world: &mut World, ) -> Result<[(Entity, Entity); N], (SpawnError, Self)>

Spawns the captured bundles within the target’s prepared sparse budgets.

Returns exactly N (old, new) pairs in source order. Old identities are informational: sources need not still exist. A different target world is allowed; old/new handles then belong to their respective worlds and may have equal bits. In the same world each new handle differs from every source identity. Hosts explicitly remap any entity references afterward.

Uses World::try_spawn_batch without weakening its admission guarantees: any reported error returns the entire plan for retry, without spawning, dropping or recloning components. No ECS buffers/metadata grow on success; preparation is the caller’s responsibility. A valid empty plan needs none. User Clone/Drop and allocator panics/aborts are not caught or rolled back. See World::plan_duplication for a complete actor-template recipe.

Trait Implementations§

Source§

impl<B: Debug + CloneBundle, const N: usize> Debug for DuplicationPlan<B, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<B, const N: usize> Freeze for DuplicationPlan<B, N>
where B: Freeze,

§

impl<B, const N: usize> RefUnwindSafe for DuplicationPlan<B, N>
where B: RefUnwindSafe,

§

impl<B, const N: usize> Send for DuplicationPlan<B, N>
where B: Send,

§

impl<B, const N: usize> Sync for DuplicationPlan<B, N>
where B: Sync,

§

impl<B, const N: usize> Unpin for DuplicationPlan<B, N>
where B: Unpin,

§

impl<B, const N: usize> UnwindSafe for DuplicationPlan<B, N>
where B: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.