#[child]Expand description
Attribute macro for individual child methods within a
#[plexus_macros::activation] impl block.
Two method shapes are accepted:
| Shape | Role | Example |
|---|---|---|
fn NAME(&self) -> Child (no args) | Static child โ routing name is the method name | fn mercury(&self) -> Mercury |
fn NAME(&self, name: &str) -> Option<Child> (sync or async) | Dynamic fallback dispatcher | fn planet(&self, name: &str) -> Option<Planet> |
The enclosing #[plexus_macros::activation] macro collects all #[child]
methods and generates a ChildRouter impl whose get_child(name)
dispatches over them. #[child] methods are not exposed as Plexus RPC
methods โ they contribute only to ChildRouter routing.
ยงExample
โ
#[plexus_macros::activation(namespace = "solar")]
impl Solar {
#[plexus_macros::child]
fn mercury(&self) -> Mercury { self.mercury.clone() }
#[plexus_macros::child]
async fn planet(&self, name: &str) -> Option<Planet> {
self.lookup_planet(name).await
}
}Used standalone (outside an #[activation] block) this attribute is a
no-op that returns the function unchanged.