laravel_rust_queue_macros/
lib.rs1mod event;
14mod job;
15mod job_middleware;
16mod listener;
17mod mailable;
18mod notification;
19mod queue;
20mod queue_callback;
21mod queueable;
22mod slack;
23mod workflow;
24
25use laravel_rust_macro_support::{self as syntax, NoArguments, attribute, expand};
26use proc_macro::TokenStream;
27
28#[proc_macro_attribute]
29pub fn listener(args: TokenStream, input: TokenStream) -> TokenStream {
30 attribute(
31 args,
32 input,
33 "`#[listener]` goes on an async function, or with `queued` on the impl of a listener struct",
34 listener::expand,
35 )
36}
37
38#[proc_macro_derive(Event, attributes(event))]
39pub fn event(input: TokenStream) -> TokenStream {
40 expand(input, event::expand)
41}
42
43#[proc_macro_derive(Queueable, attributes(serde))]
44pub fn queueable(input: TokenStream) -> TokenStream {
45 expand(input, queueable::expand)
46}
47
48#[proc_macro_derive(Mailable, attributes(mail))]
49pub fn mailable(input: TokenStream) -> TokenStream {
50 expand(input, mailable::expand)
51}
52
53#[proc_macro_attribute]
54pub fn notification(args: TokenStream, input: TokenStream) -> TokenStream {
55 attribute(
56 args,
57 input,
58 "`#[notification]` goes on the impl of a notification struct",
59 |NoArguments, implementation| notification::expand(implementation),
60 )
61}
62
63#[proc_macro_attribute]
64pub fn notification_channel(args: TokenStream, input: TokenStream) -> TokenStream {
65 attribute(
66 args,
67 input,
68 "`#[notification::channel]` goes on the impl of a channel struct",
69 notification::expand_channel,
70 )
71}
72
73#[proc_macro]
74pub fn slack_markdown(input: TokenStream) -> TokenStream {
75 expand(input, slack::expand_markdown)
76}
77
78#[proc_macro_attribute]
79pub fn slack_action(args: TokenStream, input: TokenStream) -> TokenStream {
80 attribute(
81 args,
82 input,
83 "`#[slack::action]` goes on the impl of an action struct",
84 slack::expand_action,
85 )
86}
87
88#[proc_macro_attribute]
89pub fn job(args: TokenStream, input: TokenStream) -> TokenStream {
90 attribute(
91 args,
92 input,
93 "`#[job]` goes on the impl of a job struct, as in `#[job] impl SendWelcomeEmail { .. }`",
94 job::expand,
95 )
96}
97
98#[proc_macro_attribute]
99pub fn workflow(args: TokenStream, input: TokenStream) -> TokenStream {
100 attribute(
101 args,
102 input,
103 "`#[workflow]` goes on the impl of a workflow struct, as in `#[workflow] impl OnboardUser { .. }`",
104 workflow::expand,
105 )
106}
107
108#[proc_macro_attribute]
109pub fn job_middleware(args: TokenStream, input: TokenStream) -> TokenStream {
110 attribute(
111 args,
112 input,
113 "`#[middleware]` goes on an async function",
114 |NoArguments, function| job_middleware::expand(function),
115 )
116}
117
118#[proc_macro_attribute]
119pub fn queue_callback(args: TokenStream, input: TokenStream) -> TokenStream {
120 attribute(
121 args,
122 input,
123 "`#[callback]` goes on an async function or an inherent impl",
124 queue_callback::expand_item,
125 )
126}