pub struct NodeIdMap { /* private fields */ }Expand description
The result of a DOM reconciliation, from the point of view of anyone holding
NodeId-keyed state for a single DOM.
Built from azul_core::diff::DiffResult::node_moves, which contains an entry
for EVERY matched node (including nodes that kept their index). The absence
of an old NodeId from the map therefore has a precise meaning: that node was
unmounted. This is what makes GC possible without a second “alive” set.
The contract for consumers is a single rule:
NodeIdMap::resolvereturnsSome(new_id)— the node survived, rewrite the key.NodeIdMap::resolvereturnsNone— the node is GONE, drop the state.
Never “keep it, just in case”: a kept key is a key that now denotes a different node.
Implementations§
Source§impl NodeIdMap
impl NodeIdMap
Sourcepub fn from_node_moves(node_moves: &[NodeMove]) -> Self
pub fn from_node_moves(node_moves: &[NodeMove]) -> Self
Build from reconciliation output (DiffResult::node_moves).
Sourcepub fn from_pairs<I: IntoIterator<Item = (NodeId, NodeId)>>(pairs: I) -> Self
pub fn from_pairs<I: IntoIterator<Item = (NodeId, NodeId)>>(pairs: I) -> Self
Build from raw (old, new) pairs — used by tests and by callers that
already computed a migration map.
Sourcepub fn resolve(&self, old: NodeId) -> Option<NodeId>
pub fn resolve(&self, old: NodeId) -> Option<NodeId>
Some(new_id) if the node survived the rebuild, None if it was unmounted.
Sourcepub fn is_unmounted(&self, old: NodeId) -> bool
pub fn is_unmounted(&self, old: NodeId) -> bool
true if old no longer exists in the new DOM.
Sourcepub fn resolve_dom_node_id(
&self,
dom: DomId,
id: DomNodeId,
) -> Option<DomNodeId>
pub fn resolve_dom_node_id( &self, dom: DomId, id: DomNodeId, ) -> Option<DomNodeId>
Resolve a full DomNodeId. Ids belonging to a different DOM are passed
through untouched (this reconciliation says nothing about them).
Sourcepub const fn as_btree_map(&self) -> &BTreeMap<NodeId, NodeId>
pub const fn as_btree_map(&self) -> &BTreeMap<NodeId, NodeId>
The raw old→new map, for azul_core APIs that take a BTreeMap
(DragContext::remap_node_ids, MultiCursorState::remap_node_ids).
Trait Implementations§
impl Eq for NodeIdMap
impl StructuralPartialEq for NodeIdMap
Auto Trait Implementations§
impl Freeze for NodeIdMap
impl RefUnwindSafe for NodeIdMap
impl Send for NodeIdMap
impl Sync for NodeIdMap
impl Unpin for NodeIdMap
impl UnsafeUnpin for NodeIdMap
impl UnwindSafe for NodeIdMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more