pub trait Child:
Identifiable
+ SignalReceiver
+ Statusable
+ Send
+ Sync {
// Provided method
fn set_context(&mut self, _ctx: Box<dyn ChildContext>) { ... }
}Expand description
A child entity managed by a Component.
All entities held inside a Component must implement this trait. This ensures they can:
- Be identified (
Identifiable) - Respond to signals (
SignalReceiver) - Report status (
Statusable)
§Object Safety
This trait is object-safe, allowing Box<dyn Child>.
§Signal Propagation
When a Component receives a signal, it MUST forward it to all children:
ⓘ
fn on_signal(&mut self, signal: &Signal) -> SignalResponse {
// Handle self first
// ...
// Forward to ALL children
for child in &mut self.children {
child.on_signal(signal);
}
}§Type Parameter Alternative
For stronger typing, Components can use:
ⓘ
struct MyComponent<C: Child> {
children: Vec<C>,
}Provided Methods§
Sourcefn set_context(&mut self, _ctx: Box<dyn ChildContext>)
fn set_context(&mut self, _ctx: Box<dyn ChildContext>)
Inject a ChildContext so the child can use orcs.* functions at
runtime (RPC, exec, spawn, file tools, etc.).
The default implementation is a no-op — override when the child
actually needs context (e.g. LuaChild).