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§
Required Methods§
Sourcefn begin_group(&mut self, key: Key) -> StartGroup<Self::Group>
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).
Sourcefn set_group_scope(&mut self, group: Self::Group, scope: usize)
fn set_group_scope(&mut self, group: Self::Group, scope: usize)
Associate the runtime recomposition scope with this group.
Sourcefn skip_current_group(&mut self)
fn skip_current_group(&mut self)
Skip over the current group (used by the “skip optimization” in the macro).
Sourcefn nodes_in_current_group(&self) -> Vec<NodeId> ⓘ
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).
Sourcefn begin_recranpose_at_scope(&mut self, scope: usize) -> Option<Self::Group>
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.
Sourcefn end_recompose(&mut self)
fn end_recompose(&mut self)
Finish the recomposition started with begin_recranpose_at_scope.
Sourcefn 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
Allocate or reuse a value slot at the current cursor.
Sourcefn read_value<T: 'static>(&self, slot: Self::ValueSlot) -> &T
fn read_value<T: 'static>(&self, slot: Self::ValueSlot) -> &T
Immutable read of a value slot.
Sourcefn 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
Mutable read of a value slot.
Sourcefn write_value<T: 'static>(&mut self, slot: Self::ValueSlot, value: T)
fn write_value<T: 'static>(&mut self, slot: Self::ValueSlot, value: T)
Overwrite an existing value slot.
Sourcefn remember<T: 'static>(&mut self, init: impl FnOnce() -> T) -> Owned<T>
fn remember<T: 'static>(&mut self, init: impl FnOnce() -> T) -> Owned<T>
Convenience “remember” built on top of value slots.
Sourcefn record_node(&mut self, id: NodeId)
fn record_node(&mut self, id: NodeId)
Record a node at the current cursor (and advance).
Sourcefn advance_after_node_read(&mut self)
fn advance_after_node_read(&mut self)
Advance after we’ve read a node via the applier path.
Sourcefn step_back(&mut self)
fn step_back(&mut self)
Step the cursor back by one (used when we probed and need to overwrite).
Sourcefn finalize_current_group(&mut self) -> bool
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).
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
impl SlotStorage for SlotBackend
Source§impl SlotStorage for ChunkedSlotStorage
impl SlotStorage for ChunkedSlotStorage
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.