1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! Proc-macro support for the kojin task queue.
//!
//! Provides the `#[kojin::task]` attribute macro that generates a task struct
//! and `Task` trait implementation from an async function. Most users should
//! use this via the [`kojin`](https://crates.io/crates/kojin) facade crate.
use TokenStream;
use parse_macro_input;
/// Derive a task struct and `Task` impl from an async function.
///
/// # Example
/// ```ignore
/// #[task(queue = "emails", max_retries = 5)]
/// async fn send_email(ctx: &TaskContext, to: String, subject: String) -> TaskResult<()> {
/// // ...
/// Ok(())
/// }
/// ```
///
/// This generates:
/// - `struct SendEmail { pub to: String, pub subject: String }`
/// - `impl Task for SendEmail { ... }`
/// - `SendEmail::new(to, subject)`