#[router_task]Expand description
Apply to the RouterTask trait definition, an
impl RouterTask<S [, K]> for T block, or — for less boilerplate — an
inherent impl T { ... } block.
Use as #[cano::task::router].
Two surface forms on impl blocks:
- Trait-impl form:
#[task::router] impl RouterTask<S> for T { async fn route(..) { ... } }— user writes the trait header. The macro async-rewrites theRouterTaskimpl AND emits a companionimpl Task<S> for Tthat delegatesTask::run→RouterTask::route. - Inherent-impl form:
#[task::router(state = S [, key = K])] impl T { async fn route(..) { ... } }— the macro builds theimpl RouterTask<S [, K]> for Theader from the attribute args, enforces thatrouteis present (config/namemay be overridden), and emits the same companionimpl Task<S [, K]> for T.
On a trait definition (#[task::router] pub trait RouterTask ...) the macro just performs the
async-fn-in-trait rewrite.
Because a blanket impl<R: RouterTask<..>> Task<..> for R would conflict (E0119) with the
analogous blanket impls for the other specialized task traits — a type can implement more than
one — the companion Task impl is generated per-use-site rather than as a blanket.