pub struct SlotTable { /* private fields */ }Implementations§
Source§impl SlotTable
impl SlotTable
pub fn new() -> Self
pub fn current_group(&self) -> usize
pub fn group_key(&self, index: usize) -> Option<Key>
Sourcepub fn mark_range_as_gaps(
&mut self,
start: usize,
end: usize,
owner_index: Option<usize>,
) -> bool
pub fn mark_range_as_gaps( &mut self, start: usize, end: usize, owner_index: Option<usize>, ) -> bool
Mark a range of slots as gaps instead of truncating. This preserves sibling components while allowing structure changes. When encountering a Group, recursively marks the entire group structure as gaps.
pub fn get_group_scope(&self, index: usize) -> Option<usize>
pub fn set_group_scope(&mut self, index: usize, scope: usize)
pub fn find_group_index_by_scope(&self, scope: usize) -> Option<usize>
pub fn start_recranpose_at_scope(&mut self, scope: usize) -> Option<usize>
pub fn debug_dump_groups(&self) -> Vec<(usize, Key, Option<usize>, usize)>
pub fn debug_dump_all_slots(&self) -> Vec<(usize, String)>
pub fn start(&mut self, key: Key) -> usize
pub fn end(&mut self)
pub fn skip_current(&mut self)
pub fn node_ids_in_current_group(&self) -> Vec<NodeId> ⓘ
pub fn use_value_slot<T: 'static>(&mut self, init: impl FnOnce() -> T) -> usize
pub fn read_value<T: 'static>(&self, idx: usize) -> &T
pub fn read_value_mut<T: 'static>(&mut self, idx: usize) -> &mut T
pub fn write_value<T: 'static>(&mut self, idx: usize, value: T)
Sourcepub fn read_value_by_anchor<T: 'static>(&self, anchor: AnchorId) -> Option<&T>
pub fn read_value_by_anchor<T: 'static>(&self, anchor: AnchorId) -> Option<&T>
Read a value slot by its anchor ID. Provides stable access even if the slot’s position changes.
Sourcepub fn read_value_mut_by_anchor<T: 'static>(
&mut self,
anchor: AnchorId,
) -> Option<&mut T>
pub fn read_value_mut_by_anchor<T: 'static>( &mut self, anchor: AnchorId, ) -> Option<&mut T>
Read a mutable value slot by its anchor ID.
pub fn remember<T: 'static>(&mut self, init: impl FnOnce() -> T) -> Owned<T>
Sourcepub fn remember_with_anchor<T: 'static>(
&mut self,
init: impl FnOnce() -> T,
) -> (usize, AnchorId)
pub fn remember_with_anchor<T: 'static>( &mut self, init: impl FnOnce() -> T, ) -> (usize, AnchorId)
Remember a value and return both its index and anchor ID. The anchor provides stable access even if the slot’s position changes.
pub fn record_node(&mut self, id: NodeId)
pub fn peek_node(&self) -> Option<NodeId>
pub fn read_node(&mut self) -> Option<NodeId>
pub fn advance_after_node_read(&mut self)
pub fn reset(&mut self)
Sourcepub fn step_back(&mut self)
pub fn step_back(&mut self)
Step the cursor back by one position. Used when we need to replace a slot that was just read but turned out to be incompatible.
Sourcepub fn trim_to_cursor(&mut self) -> bool
pub fn trim_to_cursor(&mut self) -> bool
Trim slots by marking unreachable slots as gaps.
Instead of blindly truncating at cursor position, this method:
- Marks slots from cursor to end of current group as gaps
- Keeps the group length unchanged (gaps are part of the group’s physical extent)
- Preserves sibling components outside the current group
This ensures effect states (LaunchedEffect, etc.) are preserved even when conditional rendering changes the composition structure.
Key insight: Gap slots remain part of the group’s physical length. The group’s
len field represents its physical extent in the slots array, not the count of
active slots. This allows gap slots to be found and reused in subsequent compositions.
Trait Implementations§
Source§impl SlotStorage for SlotTable
Baseline SlotStorage implementation using a gap-buffer strategy.
impl SlotStorage for SlotTable
Baseline SlotStorage implementation using a gap-buffer strategy.
This is the reference / most-feature-complete backend, supporting:
- Gap-based slot reuse (preserving sibling state during conditional rendering)
- Anchor-based positional stability during group moves and insertions
- Efficient group skipping and recomposition via scope-based entry
- Batch anchor rebuilding for large structural changes
Implementation Strategy: Uses UFCS (Uniform Function Call Syntax) to delegate to SlotTable’s inherent methods, avoiding infinite recursion while keeping the trait implementation clean.
Source§type ValueSlot = ValueSlotId
type ValueSlot = ValueSlotId
Source§fn begin_group(&mut self, key: Key) -> StartGroup<Self::Group>
fn begin_group(&mut self, key: Key) -> StartGroup<Self::Group>
Source§fn set_group_scope(&mut self, group: Self::Group, scope: usize)
fn set_group_scope(&mut self, group: Self::Group, scope: usize)
Source§fn skip_current_group(&mut self)
fn skip_current_group(&mut self)
Source§fn nodes_in_current_group(&self) -> Vec<NodeId> ⓘ
fn nodes_in_current_group(&self) -> Vec<NodeId> ⓘ
Source§fn begin_recranpose_at_scope(&mut self, scope: usize) -> Option<Self::Group>
fn begin_recranpose_at_scope(&mut self, scope: usize) -> Option<Self::Group>
scope. Returns the group we
started, or None if that scope is gone.Source§fn end_recompose(&mut self)
fn end_recompose(&mut self)
begin_recranpose_at_scope.Source§fn alloc_value_slot<T: 'static>(
&mut self,
init: impl FnOnce() -> T,
) -> Self::ValueSlot
fn alloc_value_slot<T: 'static>( &mut self, init: impl FnOnce() -> T, ) -> Self::ValueSlot
Source§fn read_value<T: 'static>(&self, slot: Self::ValueSlot) -> &T
fn read_value<T: 'static>(&self, slot: Self::ValueSlot) -> &T
Source§fn read_value_mut<T: 'static>(&mut self, slot: Self::ValueSlot) -> &mut T
fn read_value_mut<T: 'static>(&mut self, slot: Self::ValueSlot) -> &mut T
Source§fn write_value<T: 'static>(&mut self, slot: Self::ValueSlot, value: T)
fn write_value<T: 'static>(&mut self, slot: Self::ValueSlot, value: T)
Source§fn remember<T: 'static>(&mut self, init: impl FnOnce() -> T) -> Owned<T>
fn remember<T: 'static>(&mut self, init: impl FnOnce() -> T) -> Owned<T>
Source§fn record_node(&mut self, id: NodeId)
fn record_node(&mut self, id: NodeId)
Source§fn advance_after_node_read(&mut self)
fn advance_after_node_read(&mut self)
Source§fn step_back(&mut self)
fn step_back(&mut self)
Source§fn finalize_current_group(&mut self) -> bool
fn finalize_current_group(&mut self) -> bool
true if we marked gaps (which means children are unstable).