pub struct ShadowTree { /* private fields */ }Expand description
The shadow tree — owns all nodes.
Implementations§
Source§impl ShadowTree
impl ShadowTree
pub fn new() -> Self
Sourcepub fn create_node(
&mut self,
id: NodeId,
view_type: ViewType,
initial_props: HashMap<String, PropValue>,
)
pub fn create_node( &mut self, id: NodeId, view_type: ViewType, initial_props: HashMap<String, PropValue>, )
Create a new node. Does NOT insert into the tree hierarchy —
use append_child or insert_before for that.
Sourcepub fn get(&self, id: NodeId) -> Option<&ShadowNode>
pub fn get(&self, id: NodeId) -> Option<&ShadowNode>
Get a node by ID (immutable).
Sourcepub fn get_mut(&mut self, id: NodeId) -> Option<&mut ShadowNode>
pub fn get_mut(&mut self, id: NodeId) -> Option<&mut ShadowNode>
Get a node by ID (mutable).
Sourcepub fn update_props(&mut self, id: NodeId, diff: &PropsDiff)
pub fn update_props(&mut self, id: NodeId, diff: &PropsDiff)
Update props on a node. Changed props go into pending_props for the mount phase to consume.
Sourcepub fn append_child(&mut self, parent_id: NodeId, child_id: NodeId)
pub fn append_child(&mut self, parent_id: NodeId, child_id: NodeId)
Append a child to a parent node.
Sourcepub fn insert_before(
&mut self,
parent_id: NodeId,
child_id: NodeId,
before_id: NodeId,
)
pub fn insert_before( &mut self, parent_id: NodeId, child_id: NodeId, before_id: NodeId, )
Insert a child before another child in a parent’s children list.
Sourcepub fn remove_child(&mut self, parent_id: NodeId, child_id: NodeId)
pub fn remove_child(&mut self, parent_id: NodeId, child_id: NodeId)
Remove a child from its parent and the tree.
Sourcepub fn set_native_handle(&mut self, id: NodeId, handle: NativeHandle)
pub fn set_native_handle(&mut self, id: NodeId, handle: NativeHandle)
Set the native handle for a node (after platform bridge creates the view).
Sourcepub fn take_pending_props(&mut self, id: NodeId) -> PropsDiff
pub fn take_pending_props(&mut self, id: NodeId) -> PropsDiff
Take pending props (moves them out, leaving empty). Called by the mount phase after applying to native view.
Sourcepub fn children_of(&self, id: NodeId) -> &[NodeId]
pub fn children_of(&self, id: NodeId) -> &[NodeId]
Get the ordered children of a node.
Sourcepub fn ancestors(&self, id: NodeId) -> Vec<NodeId>
pub fn ancestors(&self, id: NodeId) -> Vec<NodeId>
Walk ancestors from a node up to root (inclusive). Returns [root, …, parent, node_id].
pub fn is_empty(&self) -> bool
Sourcepub fn iter(&self) -> impl Iterator<Item = (&NodeId, &ShadowNode)>
pub fn iter(&self) -> impl Iterator<Item = (&NodeId, &ShadowNode)>
Iterate all nodes (for DevTools snapshot).