pub struct Segment { /* private fields */ }Implementations§
Source§impl Segment
impl Segment
Sourcepub fn mount<C: Component + 'static>(component: C) -> Rc<Segment>
pub fn mount<C: Component + 'static>(component: C) -> Rc<Segment>
Mounts component as a reactive segment with its own effect: the effect re-runs (and bumps
the thread-local render generation) only when a signal read by this component’s view()
changes — so a leaf’s signal change costs O(this component), not O(tree).
Sourcepub fn mount_dyn(component: Rc<RefCell<dyn Component>>) -> Rc<Segment>
pub fn mount_dyn(component: Rc<RefCell<dyn Component>>) -> Rc<Segment>
As mount, but takes an already-shared component so a parent can also hold it for event
dispatch. The view path borrows it immutably; events borrow it mutably. These normally never
overlap (dispatch is batched, so flushes happen after it), but a re-entrant flush during
dispatch would otherwise panic, so the render is skipped when the component is borrowed.
Sourcepub fn mount_fn(
render: impl Fn() -> Option<RenderNode> + 'static,
) -> Rc<Segment>
pub fn mount_fn( render: impl Fn() -> Option<RenderNode> + 'static, ) -> Rc<Segment>
Core mount: render produces this segment’s RenderNode, or None to keep the previous
render unchanged (used when the underlying widget is mid event-dispatch and cannot be
borrowed — borrowing it then would panic, so we leave the last frame’s commands in place and
a later flush re-runs us).
Sourcepub fn mount_fn_named(
name: &'static str,
render: impl Fn() -> Option<RenderNode> + 'static,
) -> Rc<Segment>
pub fn mount_fn_named( name: &'static str, render: impl Fn() -> Option<RenderNode> + 'static, ) -> Rc<Segment>
As mount_fn, but records a human-readable widget name for the devtools tree inspector.
Sourcepub fn boundary(self: &Rc<Self>) -> RenderNode
pub fn boundary(self: &Rc<Self>) -> RenderNode
A reference to this segment for a parent’s view(). Cheap: clones an Rc, does not flatten.
Sourcepub fn walk(&self, out: &mut Vec<SegmentNodeInfo>)
pub fn walk(&self, out: &mut Vec<SegmentNodeInfo>)
Emits this segment’s subtree in pre-order (parent before children) into out. See
Segment::collect for how ids, depth, and bounding rects are computed.