Skip to main content

ModifierNodeChain

Struct ModifierNodeChain 

Source
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

Source

pub fn new() -> Self

An attached chain: its nodes attach as they join it.

Source

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.

Source

pub fn detach_nodes(&mut self)

Detaches all nodes in the chain.

Source

pub fn is_attached(&self) -> bool

Whether the chain’s nodes are attached.

Source

pub fn attach_nodes(&mut self, context: &mut dyn ModifierNodeContext)

Attaches all nodes in the chain.

Source

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.

Source

pub fn update_entries_in_place<'a, I>( &mut self, elements: I, element_count: usize, changed: u64, context: &mut dyn ModifierNodeContext, ) -> bool
where 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.

Source

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.

Source

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.

Source

pub fn update<I>(&mut self, elements: I, context: &mut dyn ModifierNodeContext)

Convenience wrapper that accepts any iterator of type-erased modifier elements. Elements are collected into a temporary vector before reconciliation.

Source

pub fn reset(&mut self)

Resets all nodes in the chain. This mirrors the behaviour of Jetpack Compose’s onReset callback.

Source

pub fn detach_all(&mut self)

Detaches every node in the chain and clears internal storage.

Source

pub fn len(&self) -> usize

The number of entries in the chain: its nodes and its plain elements.

Source

pub fn is_empty(&self) -> bool

Whether the chain holds no nodes.

Source

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.

Source

pub fn capabilities(&self) -> NodeCapabilities

Returns the aggregated capability mask for the entire chain.

Source

pub fn has_capability(&self, capability: NodeCapabilities) -> bool

Returns true if the chain contains at least one node with the requested capability.

Source

pub fn head(&self) -> ModifierChainNodeRef<'_>

Returns the sentinel head reference for traversal.

Source

pub fn tail(&self) -> ModifierChainNodeRef<'_>

Returns the sentinel tail reference for traversal.

Source

pub fn head_to_tail(&self) -> ModifierChainIter<'_> ⓘ

Iterates over the chain from head to tail, skipping sentinels.

Source

pub fn tail_to_head(&self) -> ModifierChainIter<'_> ⓘ

Iterates over the chain from tail to head, skipping sentinels.

Source

pub fn for_each_forward<F>(&self, f: F)

Calls f for every node in insertion order.

Source

pub fn for_each_forward_matching<F>(&self, mask: NodeCapabilities, f: F)

Calls f for every node containing any capability from mask.

Source

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.

Source

pub fn for_each_backward<F>(&self, f: F)

Calls f for every node in reverse insertion order.

Source

pub fn find_node_ref( &self, node: &dyn ModifierNode, ) -> Option<ModifierChainNodeRef<'_>>

Returns the node reference that owns node.

Source

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.

Source

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.

Source

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.

Source

pub fn plain_words(&self, index: usize) -> Option<(&'static PlainFns, &[u32])>

The table and the words of the plain element at index.

Source

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.

Source

pub fn plain<E: PlainElement>(&self, index: usize) -> Option<E>

The value of the plain element at index, when it is an E.

Source

pub fn has_nodes_for_invalidation(&self, kind: InvalidationKind) -> bool

Returns true if the chain contains any nodes matching the given invalidation kind.

Source

pub fn visit_nodes_mut<F>(&mut self, f: F)
where F: FnMut(&mut dyn ModifierNode, NodeCapabilities),

Visits every node mutably in insertion order together with its capability mask.

Trait Implementations§

Source§

impl Default for ModifierNodeChain

Source§

fn default() -> Self

Returns the “default value” for a type. 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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.