Skip to main content

SlotStorage

Trait SlotStorage 

Source
pub trait SlotStorage {
    type Group: Copy + Eq;
    type ValueSlot: Copy + Eq;

Show 19 methods // Required methods fn begin_group(&mut self, key: Key) -> StartGroup<Self::Group>; fn set_group_scope(&mut self, group: Self::Group, scope: usize); fn end_group(&mut self); fn skip_current_group(&mut self); fn nodes_in_current_group(&self) -> Vec<NodeId> ; fn begin_recranpose_at_scope(&mut self, scope: usize) -> Option<Self::Group>; fn end_recompose(&mut self); fn alloc_value_slot<T: 'static>( &mut self, init: impl FnOnce() -> T, ) -> Self::ValueSlot; fn read_value<T: 'static>(&self, slot: Self::ValueSlot) -> &T; fn read_value_mut<T: 'static>(&mut self, slot: Self::ValueSlot) -> &mut T; fn write_value<T: 'static>(&mut self, slot: Self::ValueSlot, value: T); fn remember<T: 'static>(&mut self, init: impl FnOnce() -> T) -> Owned<T>; fn peek_node(&self) -> Option<NodeId>; fn record_node(&mut self, id: NodeId); fn advance_after_node_read(&mut self); fn step_back(&mut self); fn finalize_current_group(&mut self) -> bool; fn reset(&mut self); fn flush(&mut self);
}
Expand description

Abstract slot API that the composer / composition engine talks to. Concrete backends (SlotTable with gap buffer, chunked storage, arena, etc.) implement this and can keep whatever internal layout they want.

Required Associated Types§

Source

type Group: Copy + Eq

Opaque handle to a started group.

Source

type ValueSlot: Copy + Eq

Opaque handle to a value slot.

Required Methods§

Source

fn begin_group(&mut self, key: Key) -> StartGroup<Self::Group>

Begin a group with the given key.

Returns a handle to the group and whether it was restored from a gap (which means the composer needs to force-recompose the scope).

Source

fn set_group_scope(&mut self, group: Self::Group, scope: usize)

Associate the runtime recomposition scope with this group.

Source

fn end_group(&mut self)

End the current group.

Source

fn skip_current_group(&mut self)

Skip over the current group (used by the “skip optimization” in the macro).

Source

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

Return node ids that live in the current group (needed so the composer can reattach them to the parent when skipping).

Source

fn begin_recranpose_at_scope(&mut self, scope: usize) -> Option<Self::Group>

Start recomposing the group that owns scope. Returns the group we started, or None if that scope is gone.

Source

fn end_recompose(&mut self)

Finish the recomposition started with begin_recranpose_at_scope.

Source

fn alloc_value_slot<T: 'static>( &mut self, init: impl FnOnce() -> T, ) -> Self::ValueSlot

Allocate or reuse a value slot at the current cursor.

Source

fn read_value<T: 'static>(&self, slot: Self::ValueSlot) -> &T

Immutable read of a value slot.

Source

fn read_value_mut<T: 'static>(&mut self, slot: Self::ValueSlot) -> &mut T

Mutable read of a value slot.

Source

fn write_value<T: 'static>(&mut self, slot: Self::ValueSlot, value: T)

Overwrite an existing value slot.

Source

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

Convenience “remember” built on top of value slots.

Source

fn peek_node(&self) -> Option<NodeId>

Peek a node at the current cursor (don’t advance).

Source

fn record_node(&mut self, id: NodeId)

Record a node at the current cursor (and advance).

Source

fn advance_after_node_read(&mut self)

Advance after we’ve read a node via the applier path.

Source

fn step_back(&mut self)

Step the cursor back by one (used when we probed and need to overwrite).

Source

fn finalize_current_group(&mut self) -> bool

“Finalize” the current group: mark unreachable tail as gaps. Returns true if we marked gaps (which means children are unstable).

Source

fn reset(&mut self)

Reset to the beginning (used by subcompose + top-level render).

Source

fn flush(&mut self)

Flush any deferred anchor rebuilds.

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.

Implementors§

Source§

impl SlotStorage for SlotBackend

Source§

impl SlotStorage for ChunkedSlotStorage

Source§

impl SlotStorage for HierarchicalSlotStorage

Source§

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§

impl SlotStorage for SplitSlotStorage