pub struct ComponentsView<'a> {
pub instances: Option<&'a [Option<Box<dyn ErasedComponent>>]>,
pub slots: Option<&'a HashMap<String, ComponentRef>>,
}Expand description
Read-only view onto sibling components registered on the Node.
Constructed by the engine at dispatch time from
&engine.components + &engine.slots. The Vec is indexed by
ComponentRef.as_u32() as usize; the slot the currently-
dispatching component lives in is None for the duration of
the dispatch (take-and-restore in invoke_atomic), so callers
can’t accidentally re-enter themselves.
Fields§
§instances: Option<&'a [Option<Box<dyn ErasedComponent>>]>All registered components indexed by ComponentRef.as_u32(),
borrowed from engine.components. None outside engine
context (test setups bypassing the registry).
slots: Option<&'a HashMap<String, ComponentRef>>Author-chosen-slot-name → ComponentRef map, borrowed from
engine.slots. THE canonical dependency-resolution surface.
None outside engine context.
Implementations§
Source§impl ComponentsView<'_>
impl ComponentsView<'_>
Sourcepub fn for_slot(
&self,
slot_name: &str,
) -> Option<&(dyn ErasedComponent + 'static)>
pub fn for_slot( &self, slot_name: &str, ) -> Option<&(dyn ErasedComponent + 'static)>
Look up the component bound at slot_name. The generic
dependency-resolution surface — Components reach their
declared dependencies through this accessor. Returns None
when no slot of that name is bound or when the view has no
engine context.
Sourcepub fn for_slot_as<T>(&self, slot_name: &str) -> Option<&T>where
T: 'static,
pub fn for_slot_as<T>(&self, slot_name: &str) -> Option<&T>where
T: 'static,
Look up the component bound at slot_name AND downcast it
to &T. The typed counterpart to Self::for_slot.
Returns None when the slot is unbound OR when the bound
concrete is not a T.
In production this is reached through
crate::runtime::RuntimeResourceRef::dependency, which
wraps the lookup in DependencyError variants for typed
error reporting.