pub struct ModifierNodeChain { /* private fields */ }Expand description
Chain of modifier nodes attached to a layout node.
The chain tracks ownership of modifier nodes and reuses them across updates when the incoming element list still contains a node of the same type. Removed nodes detach automatically so callers do not need to manually manage their lifetimes.
Implementations§
Source§impl ModifierNodeChain
impl ModifierNodeChain
Sourcepub fn detached() -> Self
pub fn detached() -> Self
A detached chain: its nodes attach at Self::attach_nodes, as a
layout node’s do once the node has its id.
Sourcepub fn detach_nodes(&mut self)
pub fn detach_nodes(&mut self)
Detaches all nodes in the chain.
Sourcepub fn is_attached(&self) -> bool
pub fn is_attached(&self) -> bool
Whether the chain’s nodes are attached.
Sourcepub fn attach_nodes(&mut self, context: &mut dyn ModifierNodeContext)
pub fn attach_nodes(&mut self, context: &mut dyn ModifierNodeContext)
Attaches all nodes in the chain.
Sourcepub fn update_from_slice(
&mut self,
elements: &[DynModifierElement],
context: &mut dyn ModifierNodeContext,
)
pub fn update_from_slice( &mut self, elements: &[DynModifierElement], context: &mut dyn ModifierNodeContext, )
Reconcile the chain against the provided elements, attaching newly created nodes and detaching nodes that are no longer required.
This method delegates to update_from_ref_iter which handles the
actual reconciliation logic.
Sourcepub fn update_entries_in_place<'a, I>(
&mut self,
elements: I,
element_count: usize,
changed: u64,
context: &mut dyn ModifierNodeContext,
) -> boolwhere
I: Iterator<Item = &'a DynModifierElement>,
pub fn update_entries_in_place<'a, I>(
&mut self,
elements: I,
element_count: usize,
changed: u64,
context: &mut dyn ModifierNodeContext,
) -> boolwhere
I: Iterator<Item = &'a DynModifierElement>,
Updates in place the entries changed names, one bit an index, for
elements that differ from the chain’s only in those: entries and
elements line up one to one, and every other entry stays as it is.
false when they do not line up or an entry cannot take its element;
a full update then reconciles the chain.
Sourcepub fn invalidate_last(&self, context: &mut dyn ModifierNodeContext)
pub fn invalidate_last(&self, context: &mut dyn ModifierNodeContext)
Asks context for what an update of the last node’s values
invalidates, by the node’s capabilities, after its caller updated the
node in place and left its capabilities as they were.
Sourcepub fn update_from_ref_iter<'a, I>(
&mut self,
elements: I,
context: &mut dyn ModifierNodeContext,
)where
I: Iterator<Item = &'a DynModifierElement>,
pub fn update_from_ref_iter<'a, I>(
&mut self,
elements: I,
context: &mut dyn ModifierNodeContext,
)where
I: Iterator<Item = &'a DynModifierElement>,
Reconciles the chain against the elements that elements yields, without collecting them
first. See update_from_slice.
Sourcepub fn update<I>(&mut self, elements: I, context: &mut dyn ModifierNodeContext)where
I: IntoIterator<Item = DynModifierElement>,
pub fn update<I>(&mut self, elements: I, context: &mut dyn ModifierNodeContext)where
I: IntoIterator<Item = DynModifierElement>,
Convenience wrapper that accepts any iterator of type-erased modifier elements. Elements are collected into a temporary vector before reconciliation.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Resets all nodes in the chain. This mirrors the behaviour of
Jetpack Compose’s onReset callback.
Sourcepub fn detach_all(&mut self)
pub fn detach_all(&mut self)
Detaches every node in the chain and clears internal storage.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
The number of entries in the chain: its nodes and its plain elements.
Sourcepub fn held_elements(&self) -> impl ExactSizeIterator<Item = HeldElement<'_>>
pub fn held_elements(&self) -> impl ExactSizeIterator<Item = HeldElement<'_>>
The elements of the chain’s nodes, one for each in chain order: those the chain was last updated from, or equal ones it kept, or the nodes that hold every value of them.
Sourcepub fn capabilities(&self) -> NodeCapabilities
pub fn capabilities(&self) -> NodeCapabilities
Returns the aggregated capability mask for the entire chain.
Sourcepub fn has_capability(&self, capability: NodeCapabilities) -> bool
pub fn has_capability(&self, capability: NodeCapabilities) -> bool
Returns true if the chain contains at least one node with the requested capability.
Sourcepub fn head(&self) -> ModifierChainNodeRef<'_>
pub fn head(&self) -> ModifierChainNodeRef<'_>
Returns the sentinel head reference for traversal.
Sourcepub fn tail(&self) -> ModifierChainNodeRef<'_>
pub fn tail(&self) -> ModifierChainNodeRef<'_>
Returns the sentinel tail reference for traversal.
Sourcepub fn head_to_tail(&self) -> ModifierChainIter<'_> ⓘ
pub fn head_to_tail(&self) -> ModifierChainIter<'_> ⓘ
Iterates over the chain from head to tail, skipping sentinels.
Sourcepub fn tail_to_head(&self) -> ModifierChainIter<'_> ⓘ
pub fn tail_to_head(&self) -> ModifierChainIter<'_> ⓘ
Iterates over the chain from tail to head, skipping sentinels.
Sourcepub fn for_each_forward<F>(&self, f: F)where
F: FnMut(ModifierChainNodeRef<'_>),
pub fn for_each_forward<F>(&self, f: F)where
F: FnMut(ModifierChainNodeRef<'_>),
Calls f for every node in insertion order.
Sourcepub fn for_each_forward_matching<F>(&self, mask: NodeCapabilities, f: F)where
F: FnMut(ModifierChainNodeRef<'_>),
pub fn for_each_forward_matching<F>(&self, mask: NodeCapabilities, f: F)where
F: FnMut(ModifierChainNodeRef<'_>),
Calls f for every node containing any capability from mask.
Sourcepub fn for_each_node_with_capability<F>(&self, mask: NodeCapabilities, f: F)
pub fn for_each_node_with_capability<F>(&self, mask: NodeCapabilities, f: F)
Calls f for every node containing any capability from mask, providing the node ref.
Sourcepub fn for_each_backward<F>(&self, f: F)where
F: FnMut(ModifierChainNodeRef<'_>),
pub fn for_each_backward<F>(&self, f: F)where
F: FnMut(ModifierChainNodeRef<'_>),
Calls f for every node in reverse insertion order.
Sourcepub fn find_node_ref(
&self,
node: &dyn ModifierNode,
) -> Option<ModifierChainNodeRef<'_>>
pub fn find_node_ref( &self, node: &dyn ModifierNode, ) -> Option<ModifierChainNodeRef<'_>>
Returns the node reference that owns node.
Sourcepub fn node<N: ModifierNode + 'static>(
&self,
index: usize,
) -> Option<Ref<'_, N>>
pub fn node<N: ModifierNode + 'static>( &self, index: usize, ) -> Option<Ref<'_, N>>
Downcasts the node at index to the requested type.
Returns a Ref guard that dereferences to the node type.
Sourcepub fn node_mut<N: ModifierNode + 'static>(
&self,
index: usize,
) -> Option<RefMut<'_, N>>
pub fn node_mut<N: ModifierNode + 'static>( &self, index: usize, ) -> Option<RefMut<'_, N>>
Downcasts the node at index to the requested mutable type.
Returns a RefMut guard that dereferences to the node type.
Sourcepub fn get_node_rc(
&self,
index: usize,
) -> Option<&Rc<RefCell<dyn ModifierNode>>>
pub fn get_node_rc( &self, index: usize, ) -> Option<&Rc<RefCell<dyn ModifierNode>>>
Returns the shared node at the given index, None for a plain
element, which has none. Coordinators compare it with the node they
hold and clone it only to hold a new one.
Sourcepub fn plain_words(&self, index: usize) -> Option<(&'static PlainFns, &[u32])>
pub fn plain_words(&self, index: usize) -> Option<(&'static PlainFns, &[u32])>
The table and the words of the plain element at index.
Sourcepub fn plain_layout(
&self,
index: usize,
) -> Option<(Option<&'static PlainLayoutFns>, &[u32; 5])>
pub fn plain_layout( &self, index: usize, ) -> Option<(Option<&'static PlainLayoutFns>, &[u32; 5])>
How the plain element at index measures, with every word of its
entry: the words past the element’s own are zero.
Sourcepub fn plain<E: PlainElement>(&self, index: usize) -> Option<E>
pub fn plain<E: PlainElement>(&self, index: usize) -> Option<E>
The value of the plain element at index, when it is an E.
Sourcepub fn has_nodes_for_invalidation(&self, kind: InvalidationKind) -> bool
pub fn has_nodes_for_invalidation(&self, kind: InvalidationKind) -> bool
Returns true if the chain contains any nodes matching the given invalidation kind.
Sourcepub fn visit_nodes_mut<F>(&mut self, f: F)
pub fn visit_nodes_mut<F>(&mut self, f: F)
Visits every node mutably in insertion order together with its capability mask.