Skip to main content

Crate cano_macros

Crate cano_macros 

Source
Expand description

§cano-macros

Procedural macros backing the cano workflow engine.

The crate exposes one attribute macro per cano core trait, all of which perform the same async-fn-to-Pin<Box<dyn Future + Send>> rewrite that the async-trait crate does. Splitting the macro by trait name (rather than a single generic async_trait) gives a more self-documenting attribute at the developer side: #[cano::task] on impl Task is immediately scannable for what the impl is.

These macros are intended to be used via their namespaced paths in cano:

  • #[cano::task] — for impl Task (and the Task trait definition itself)
  • #[cano::task::router] — for impl RouterTask and the RouterTask trait
  • #[cano::task::poll] — for impl PollTask and the PollTask trait
  • #[cano::task::timer] — for impl TimerTask and the TimerTask trait
  • #[cano::task::batch] — for impl BatchTask and the BatchTask trait
  • #[cano::task::stepped] — for impl SteppedTask and the SteppedTask trait
  • #[cano::task::stream] — for impl StreamTask and the StreamTask trait
  • #[cano::saga::task] — for impl CompensatableTask
  • #[cano::resource] — for impl Resource and the Resource trait
  • #[cano::checkpoint_store] — for impl CheckpointStore and the CheckpointStore trait

All are functionally identical in the async-rewrite they perform; they differ only in name. New traits that need async-fn-in-dyn rewriting can ship their own cano-macros attribute alongside.

Attribute Macros§

batch_task
Apply to the BatchTask trait definition, an impl BatchTask<S [, K]> for T block, or — for less boilerplate — an inherent impl T { ... } block.
checkpoint_store
Apply to the CheckpointStore trait definition, an impl CheckpointStore for T block, or — for less boilerplate — an inherent impl T { ... } block.
compensatable_task
Apply to the CompensatableTask trait definition, an impl CompensatableTask<S [, K]> for T block, or — for less boilerplate — an inherent impl T { ... } block.
poll_task
Apply to the PollTask trait definition, an impl PollTask<S [, K]> for T block, or — for less boilerplate — an inherent impl T { ... } block.
resource
Apply to impl Resource for ... blocks (or the Resource trait definition itself).
router_task
Apply to the RouterTask trait definition, an impl RouterTask<S [, K]> for T block, or — for less boilerplate — an inherent impl T { ... } block.
stepped_task
Apply to the SteppedTask trait definition, an impl SteppedTask<S [, K]> for T block, or — for less boilerplate — an inherent impl T { ... } block.
stream_task
Apply to the StreamTask trait definition, an impl StreamTask<S [, K]> for T block, or an inherent impl T { ... } block.
task
Apply to impl Task for ... blocks (or the Task trait definition itself).
timer_task
Apply to the TimerTask trait definition, an impl TimerTask<S [, K]> for T block, or — for less boilerplate — an inherent impl T { ... } block.

Derive Macros§

FromResources
Derive a from_resources(&Resources<_>) -> CanoResult<Self> constructor that pulls each field out of a cano::Resources map.
Resource
Derive an empty cano::Resource impl (uses the trait’s default no-op setup / teardown).