Skip to main content

SlotTable

Struct SlotTable 

Source
pub struct SlotTable { /* private fields */ }

Implementations§

Source§

impl SlotTable

Source

pub fn new() -> Self

Source

pub fn heap_bytes(&self) -> usize

Returns approximate heap bytes used by this slot table.

Source

pub fn debug_stats(&self) -> SlotTableDebugStats

Source

pub fn current_group(&self) -> usize

Source

pub fn group_key(&self, index: usize) -> Option<Key>

Source

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.

Source

pub fn get_group_scope(&self, index: usize) -> Option<usize>

Source

pub fn set_group_scope(&mut self, index: usize, scope: usize)

Source

pub fn start_recranpose_at_anchor( &mut self, anchor: AnchorId, owner: usize, ) -> Option<usize>

Source

pub fn debug_dump_groups(&self) -> Vec<(usize, Key, Option<usize>, usize)>

Source

pub fn debug_dump_all_slots(&self) -> Vec<(usize, String)>

Source

pub fn debug_value_type_counts( &self, limit: usize, ) -> Vec<SlotValueTypeDebugStat>

Source

pub fn start(&mut self, key: Key) -> usize

Source

pub fn end(&mut self)

Source

pub fn end_recompose(&mut self)

Source

pub fn skip_current(&mut self)

Source

pub fn node_ids_in_current_group(&self) -> Vec<NodeId>

Source

pub fn descendant_scopes_in_current_group( &self, current_scope: usize, ) -> Vec<RecomposeScope>

Source

pub fn use_value_slot<T: 'static>(&mut self, init: impl FnOnce() -> T) -> usize

Source

pub fn read_value<T: 'static>(&self, idx: usize) -> &T

Source

pub fn read_value_mut<T: 'static>(&mut self, idx: usize) -> &mut T

Source

pub fn write_value<T: 'static>(&mut self, idx: usize, value: T)

Source

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.

Source

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.

Source

pub fn remember<T: 'static>(&mut self, init: impl FnOnce() -> T) -> Owned<T>

Source

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.

Source

pub fn record_node(&mut self, id: NodeId, gen: u32)

Source

pub fn peek_node(&self) -> Option<(NodeId, u32)>

Source

pub fn read_node(&mut self) -> Option<NodeId>

Source

pub fn advance_after_node_read(&mut self)

Source

pub fn reset(&mut self)

Source

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.

Source

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:

  1. Marks slots from cursor to end of current group as gaps
  2. Keeps the group length unchanged (gaps are part of the group’s physical extent)
  3. 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.

Source

pub fn drain_orphaned_node_ids_with( &mut self, visitor: impl FnMut(OrphanedNode), )

Drain orphaned node IDs collected during gap marking.

Source

pub fn drain_orphaned_node_ids(&mut self) -> Vec<OrphanedNode>

Source

pub fn compact(&mut self)

Remove all Gap slots from the slot table, recalculate Group extents, and rebuild anchor positions. This reclaims memory that accumulated when groups shrank (e.g. recursive layout depth decrease, tab switching).

Only runs when needs_compact was set by mark_range_as_gaps.

Source§

impl SlotTable

Source

pub fn begin_group(&mut self, key: Key) -> StartGroup<GroupId>

Source

pub fn end_group(&mut self)

Source

pub fn skip_current_group(&mut self)

Source

pub fn nodes_in_current_group(&self) -> Vec<NodeId>

Source

pub fn finalize_current_group(&mut self) -> bool

Source

pub fn flush(&mut self)

Trait Implementations§

Source§

impl Default for SlotTable

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for SlotTable

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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.