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]— forimpl Task(and theTasktrait definition itself)#[cano::task::router]— forimpl RouterTaskand theRouterTasktrait#[cano::task::poll]— forimpl PollTaskand thePollTasktrait#[cano::task::timer]— forimpl TimerTaskand theTimerTasktrait#[cano::task::batch]— forimpl BatchTaskand theBatchTasktrait#[cano::task::stepped]— forimpl SteppedTaskand theSteppedTasktrait#[cano::task::stream]— forimpl StreamTaskand theStreamTasktrait#[cano::saga::task]— forimpl CompensatableTask#[cano::resource]— forimpl Resourceand theResourcetrait#[cano::checkpoint_store]— forimpl CheckpointStoreand theCheckpointStoretrait
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
BatchTasktrait definition, animpl BatchTask<S [, K]> for Tblock, or — for less boilerplate — an inherentimpl T { ... }block. - checkpoint_
store - Apply to the
CheckpointStoretrait definition, animpl CheckpointStore for Tblock, or — for less boilerplate — an inherentimpl T { ... }block. - compensatable_
task - Apply to the
CompensatableTasktrait definition, animpl CompensatableTask<S [, K]> for Tblock, or — for less boilerplate — an inherentimpl T { ... }block. - poll_
task - Apply to the
PollTasktrait definition, animpl PollTask<S [, K]> for Tblock, or — for less boilerplate — an inherentimpl T { ... }block. - resource
- Apply to
impl Resource for ...blocks (or theResourcetrait definition itself). - router_
task - Apply to the
RouterTasktrait definition, animpl RouterTask<S [, K]> for Tblock, or — for less boilerplate — an inherentimpl T { ... }block. - stepped_
task - Apply to the
SteppedTasktrait definition, animpl SteppedTask<S [, K]> for Tblock, or — for less boilerplate — an inherentimpl T { ... }block. - stream_
task - Apply to the
StreamTasktrait definition, animpl StreamTask<S [, K]> for Tblock, or an inherentimpl T { ... }block. - task
- Apply to
impl Task for ...blocks (or theTasktrait definition itself). - timer_
task - Apply to the
TimerTasktrait definition, animpl TimerTask<S [, K]> for Tblock, or — for less boilerplate — an inherentimpl T { ... }block.
Derive Macros§
- From
Resources - Derive a
from_resources(&Resources<_>) -> CanoResult<Self>constructor that pulls each field out of acano::Resourcesmap. - Resource
- Derive an empty
cano::Resourceimpl (uses the trait’s default no-opsetup/teardown).