Skip to main content

RustdvComp

Struct RustdvComp 

Source
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

Source

pub fn fixed(node: Box<dyn ComponentNode>) -> RustdvComp

A fixed slot: new_comp(). Never overridden.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn put_node(&mut self, node: Box<dyn ComponentNode>)

Put a component taken by RustdvComp::take_node back into the slot.

Source

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

Source§

fn default() -> RustdvComp

Returns the “default value” for a type. Read more
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.

Source§

fn owner_port_slot(&self, name: &str) -> Option<Rc<dyn Any>>

The binding cell of the named port, erased.
Source§

fn owner_label(&self) -> &'static str

The component’s type name, for connection errors.

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.