Struct NodePool
pub struct NodePool<const CAP: usize = 1024> {
pub records: [SceneNodeRecord; CAP],
pub generations: [u32; CAP],
pub active: [bool; CAP],
pub free_indices: [u32; CAP],
pub free_len: usize,
pub active_count: usize,
pub current_tick: u32,
}Expand description
Fixed-capacity, zero-heap generational scene node pool.
Supports $O(1)$ spawn, despawn, get, get_mut, attach_child, and detach_from_parent.
Fields§
§records: [SceneNodeRecord; CAP]Contiguous node storage array.
generations: [u32; CAP]Per-slot generation counters (0 before first allocation; incremented on spawn/despawn).
active: [bool; CAP]Per-slot occupancy mask.
free_indices: [u32; CAP]LIFO stack of free slot indices.
free_len: usizeNumber of valid entries in free_indices.
active_count: usizeNumber of currently active nodes.
current_tick: u32Current monotonically advancing change-detection tick.
Implementations§
§impl<const CAP: usize> NodePool<CAP>
impl<const CAP: usize> NodePool<CAP>
pub fn new() -> NodePool<CAP>
pub fn new() -> NodePool<CAP>
Creates an empty generational node pool with all CAP slots on the free list.
pub fn as_slice_view(&mut self) -> NodePoolSlice<'_>
pub fn as_slice_view(&mut self) -> NodePoolSlice<'_>
Borrows this pool as a slice-backed NodePoolSlice view.
pub fn advance_tick(&mut self) -> u32
pub fn advance_tick(&mut self) -> u32
Advances the pool’s change-detection tick counter.
pub fn is_valid(&self, handle: NodeHandle) -> bool
pub fn is_valid(&self, handle: NodeHandle) -> bool
Returns true if handle refers to a currently live node with matching generation.
pub fn spawn(&mut self, record: SceneNodeRecord) -> Option<NodeHandle>
pub fn spawn(&mut self, record: SceneNodeRecord) -> Option<NodeHandle>
Spawns a new SceneNodeRecord in $O(1)$ time without heap allocation.
pub fn despawn(&mut self, handle: NodeHandle) -> bool
pub fn despawn(&mut self, handle: NodeHandle) -> bool
Despawns handle in $O(1)$ time, unlinking it from its parent and detaching direct children.
pub fn get(&self, handle: NodeHandle) -> Option<&SceneNodeRecord>
pub fn get(&self, handle: NodeHandle) -> Option<&SceneNodeRecord>
Shared $O(1)$ lookup by NodeHandle.
pub fn get_mut(&mut self, handle: NodeHandle) -> Option<&mut SceneNodeRecord>
pub fn get_mut(&mut self, handle: NodeHandle) -> Option<&mut SceneNodeRecord>
Mutable $O(1)$ lookup by NodeHandle; automatically stamps changed_tick = current_tick.
pub fn attach_child(&mut self, parent: NodeHandle, child: NodeHandle) -> bool
pub fn attach_child(&mut self, parent: NodeHandle, child: NodeHandle) -> bool
Attaches child to parent in $O(1)$ using the intrusive sibling doubly-linked list.
pub fn detach_from_parent(&mut self, child: NodeHandle) -> bool
pub fn detach_from_parent(&mut self, child: NodeHandle) -> bool
Detaches child from its current parent in $O(1)$ time.
Trait Implementations§
Auto Trait Implementations§
impl<const CAP: usize> Freeze for NodePool<CAP>
impl<const CAP: usize> RefUnwindSafe for NodePool<CAP>
impl<const CAP: usize> Send for NodePool<CAP>
impl<const CAP: usize> Sync for NodePool<CAP>
impl<const CAP: usize> Unpin for NodePool<CAP>
impl<const CAP: usize> UnsafeUnpin for NodePool<CAP>
impl<const CAP: usize> UnwindSafe for NodePool<CAP>
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more