pub struct RustdvComp { /* private fields */ }Expand description
A slot that holds any component. It says nothing about position in the
tree and nothing about overridability; the build line decides that
(new_comp() fixed, create_comp() overridable). Every child field a
block may want to override is an RustdvComp.
Implementations§
Source§impl RustdvComp
impl RustdvComp
Sourcepub fn fixed(node: Box<dyn ComponentNode>) -> RustdvComp
pub fn fixed(node: Box<dyn ComponentNode>) -> RustdvComp
A fixed slot: new_comp(). Never overridden.
Sourcepub fn overridable(
node: Box<dyn ComponentNode>,
requested: &'static str,
) -> RustdvComp
pub fn overridable( node: Box<dyn ComponentNode>, requested: &'static str, ) -> RustdvComp
A factory slot: create_comp(). The default is built now and may be
swapped for an override during the walk.
Sourcepub fn as_node(&self) -> Option<&(dyn ComponentNode + 'static)>
pub fn as_node(&self) -> Option<&(dyn ComponentNode + 'static)>
The held component, shared, for asking it things — chiefly for one of
its ports during connect. None before the slot is built.
Sourcepub fn as_node_mut(&mut self) -> Option<&mut (dyn ComponentNode + 'static)>
pub fn as_node_mut(&mut self) -> Option<&mut (dyn ComponentNode + 'static)>
The held component, for the traversal. None before it is filled.
The object lifetime is 'static (a boxed component always is), which
matches ComponentNode::children_mut’s element type.
Sourcepub fn take_node(&mut self) -> Option<Box<dyn ComponentNode>>
pub fn take_node(&mut self) -> Option<Box<dyn ComponentNode>>
Move the held component out of the slot, leaving it empty (D82b).
This is what lets a parent’s run be concurrent with its children’s.
While the box sits in the slot it is part of the parent, so &mut parent and &mut child overlap and cannot both exist. Once moved out
it is an independent value with no borrow relationship to the parent,
so both futures can be driven together.
The slot is empty only for the duration of the run phase;
RustdvComp::put_node restores it before the post-run phases walk the tree.
Sourcepub fn put_node(&mut self, node: Box<dyn ComponentNode>)
pub fn put_node(&mut self, node: Box<dyn ComponentNode>)
Put a component taken by RustdvComp::take_node back into the slot.
Sourcepub fn resolve(&mut self, ctx: &RustdvCtx, name: &str)
pub fn resolve(&mut self, ctx: &RustdvCtx, name: &str)
Called by the derive-generated resolver during the build walk, with this slot’s field name. If flagged and an override applies at the slot’s path, swap it in. The discarded default’s phases never ran — resolution happens before the walk descends into the child.
Trait Implementations§
Source§impl Default for RustdvComp
impl Default for RustdvComp
Source§fn default() -> RustdvComp
fn default() -> RustdvComp
Source§impl PortOwner for RustdvComp
A slot is a PortOwner, so connect(&self.producer, ..) works on an
erased child exactly as connect(self, ..) works on the connecting
component. Both questions are answered by a ComponentNode method, which
is reachable through dyn — no cast to the child’s concrete type, which
Rust would not allow anyway.
impl PortOwner for RustdvComp
A slot is a PortOwner, so connect(&self.producer, ..) works on an
erased child exactly as connect(self, ..) works on the connecting
component. Both questions are answered by a ComponentNode method, which
is reachable through dyn — no cast to the child’s concrete type, which
Rust would not allow anyway.