Skip to main content

Composer

Struct Composer 

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

Implementations§

Source§

impl Composer

Source

pub fn new( slots: Rc<SlotsHost>, applier: Rc<dyn ApplierHost>, runtime: RuntimeHandle, observer: SnapshotStateObserver, root: Option<NodeId>, ) -> Self

Source

pub fn register_virtual_node( &self, node_id: NodeId, node: Box<dyn Node>, ) -> Result<(), NodeError>

Registers a virtual node in the Applier.

This is used by SubcomposeLayoutNode to register virtual container nodes so that subsequent insert_child commands can find them and attach children. Without this, virtual nodes would only exist in SubcomposeLayoutNodeInner.virtual_nodes and applier.get_mut(virtual_node_id) would fail, breaking child attachment.

Source

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

Checks if a node has no parent (is a root node). Used by SubcomposeMeasureScope to filter subcompose results.

Source

pub fn get_node_children(&self, node_id: NodeId) -> Vec<NodeId>

Gets the children of a node from the Applier.

This is used by SubcomposeLayoutNode to get children of virtual nodes directly from the Applier, where insert_child commands have been applied.

Source

pub fn clear_node_children(&self, node_id: NodeId)

Clears all children of a node in the Applier.

This is used by SubcomposeLayoutNode when reusing a virtual node for different content. Without clearing, old children remain attached, causing duplicate/interleaved items in lazy lists after scrolling.

Source

pub fn install<R>(&self, f: impl FnOnce(&Composer) -> R) -> R

Source

pub fn with_group<R>(&self, key: Key, f: impl FnOnce(&Composer) -> R) -> R

Source

pub fn cranpose_with_reuse<R>( &self, key: Key, options: RecomposeOptions, f: impl FnOnce(&Composer) -> R, ) -> R

Source

pub fn with_key<K: Hash, R>(&self, key: &K, f: impl FnOnce(&Composer) -> R) -> R

Source

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

Source

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

Source

pub fn with_slot_value<T: 'static, R>( &self, idx: usize, f: impl FnOnce(&T) -> R, ) -> R

Source

pub fn with_slot_value_mut<T: 'static, R>( &self, idx: usize, f: impl FnOnce(&mut T) -> R, ) -> R

Source

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

Source

pub fn mutable_state_of<T: Clone + 'static>( &self, initial: T, ) -> MutableState<T>

Source

pub fn mutable_state_list_of<T, I>(&self, values: I) -> SnapshotStateList<T>
where T: Clone + 'static, I: IntoIterator<Item = T>,

Source

pub fn mutable_state_map_of<K, V, I>(&self, pairs: I) -> SnapshotStateMap<K, V>
where K: Clone + Eq + Hash + 'static, V: Clone + 'static, I: IntoIterator<Item = (K, V)>,

Source

pub fn read_composition_local<T: Clone + 'static>( &self, local: &CompositionLocal<T>, ) -> T

Source

pub fn read_static_composition_local<T: Clone + 'static>( &self, local: &StaticCompositionLocal<T>, ) -> T

Source

pub fn current_recranpose_scope(&self) -> Option<RecomposeScope>

Source

pub fn phase(&self) -> Phase

Source

pub fn enter_phase(&self, phase: Phase)

Source

pub fn subcompose_measurement<R>( &self, state: &mut SubcomposeState, slot_id: SlotId, content: impl FnOnce(&Composer) -> R, ) -> (R, Vec<NodeId>)

Source

pub fn subcompose_in<R>( &self, slots: &Rc<SlotsHost>, root: Option<NodeId>, f: impl FnOnce(&Composer) -> R, ) -> Result<R, NodeError>

Source

pub fn subcompose_slot<R>( &self, slots: &Rc<SlotsHost>, root: Option<NodeId>, f: impl FnOnce(&Composer) -> R, ) -> Result<R, NodeError>

Subcomposes content using an isolated SlotsHost without resetting it. Unlike subcompose_in, this preserves existing slot state across calls, allowing efficient reuse during measurement passes. This is critical for lazy lists where items need stable slot positions.

Source

pub fn skip_current_group(&self)

Source

pub fn runtime_handle(&self) -> RuntimeHandle

Source

pub fn set_recranpose_callback<F>(&self, callback: F)
where F: FnMut(&Composer) + 'static,

Source

pub fn with_composition_locals<R>( &self, provided: Vec<ProvidedValue>, f: impl FnOnce(&Composer) -> R, ) -> R

Source

pub fn use_state<T: Clone + 'static>( &self, init: impl FnOnce() -> T, ) -> MutableState<T>

Source

pub fn emit_node<N: Node + 'static>(&self, init: impl FnOnce() -> N) -> NodeId

Source

pub fn with_node_mut<N: Node + 'static, R>( &self, id: NodeId, f: impl FnOnce(&mut N) -> R, ) -> Result<R, NodeError>

Source

pub fn push_parent(&self, id: NodeId)

Source

pub fn pop_parent(&self)

Source

pub fn take_commands( &self, ) -> Vec<Box<dyn FnMut(&mut dyn Applier) -> Result<(), NodeError> + 'static>>

Source

pub fn apply_pending_commands(&self) -> Result<(), NodeError>

Applies any pending applier commands and runtime updates.

This is useful during measure-time subcomposition to ensure newly created nodes are available for measurement before the full composition is committed.

Source

pub fn register_side_effect(&self, effect: impl FnOnce() + 'static)

Source

pub fn take_side_effects(&self) -> Vec<Box<dyn FnOnce()>>

Trait Implementations§

Source§

impl Clone for Composer

Source§

fn clone(&self) -> Composer

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.