Skip to main content

SubcomposeMeasureScope

Trait SubcomposeMeasureScope 

Source
pub trait SubcomposeMeasureScope: SubcomposeLayoutScope {
    // Required methods
    fn subcompose<K, Content>(
        &mut self,
        slot_id: SlotId,
        key: K,
        content: Content,
    ) -> Vec<SubcomposeChild>
       where K: PartialEq + 'static,
             Content: FnMut() + 'static;
    fn measure(
        &mut self,
        child: SubcomposeChild,
        constraints: Constraints,
    ) -> Placeable;
    fn node_has_no_parent(&self, node_id: NodeId) -> bool;
}
Expand description

Public trait exposed to measure policies for subcomposition.

Required Methods§

Source

fn subcompose<K, Content>( &mut self, slot_id: SlotId, key: K, content: Content, ) -> Vec<SubcomposeChild>
where K: PartialEq + 'static, Content: FnMut() + 'static,

Composes content into the slot, or reuses the retained composition when it is provably current.

key must carry every value that flows into content from the measure policy itself rather than from reactive state — a scaffold’s computed padding, a box’s constraints. Such values never invalidate a recompose scope when they change, so an equal key is the caller’s promise that the retained composition is not stale on that channel. Values read from reactive state inside content need no key entry: their writes invalidate the slot’s scopes and block reuse. Content must not read a non-reactive container (Cell, RefCell) for a value that changes between measure passes unless that value is part of key; debug builds recompose skipped slots and panic when the retained topology diverges from a fresh composition.

Source

fn measure( &mut self, child: SubcomposeChild, constraints: Constraints, ) -> Placeable

Measures a subcomposed child with the given constraints.

Source

fn node_has_no_parent(&self, node_id: NodeId) -> bool

Checks if a node has no parent (is a root node). Used to filter subcompose results to only include true root nodes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§