mod event;
mod job;
mod job_middleware;
mod listener;
mod mailable;
mod notification;
mod queue;
mod queue_callback;
mod queueable;
mod slack;
mod workflow;
use laravel_rust_macro_support::{self as syntax, NoArguments, attribute, expand};
use proc_macro::TokenStream;
#[proc_macro_attribute]
pub fn listener(args: TokenStream, input: TokenStream) -> TokenStream {
attribute(
args,
input,
"`#[listener]` goes on an async function, or with `queued` on the impl of a listener struct",
listener::expand,
)
}
#[proc_macro_derive(Event, attributes(event))]
pub fn event(input: TokenStream) -> TokenStream {
expand(input, event::expand)
}
#[proc_macro_derive(Queueable, attributes(serde))]
pub fn queueable(input: TokenStream) -> TokenStream {
expand(input, queueable::expand)
}
#[proc_macro_derive(Mailable, attributes(mail))]
pub fn mailable(input: TokenStream) -> TokenStream {
expand(input, mailable::expand)
}
#[proc_macro_attribute]
pub fn notification(args: TokenStream, input: TokenStream) -> TokenStream {
attribute(
args,
input,
"`#[notification]` goes on the impl of a notification struct",
|NoArguments, implementation| notification::expand(implementation),
)
}
#[proc_macro_attribute]
pub fn notification_channel(args: TokenStream, input: TokenStream) -> TokenStream {
attribute(
args,
input,
"`#[notification::channel]` goes on the impl of a channel struct",
notification::expand_channel,
)
}
#[proc_macro]
pub fn slack_markdown(input: TokenStream) -> TokenStream {
expand(input, slack::expand_markdown)
}
#[proc_macro_attribute]
pub fn slack_action(args: TokenStream, input: TokenStream) -> TokenStream {
attribute(
args,
input,
"`#[slack::action]` goes on the impl of an action struct",
slack::expand_action,
)
}
#[proc_macro_attribute]
pub fn job(args: TokenStream, input: TokenStream) -> TokenStream {
attribute(
args,
input,
"`#[job]` goes on the impl of a job struct, as in `#[job] impl SendWelcomeEmail { .. }`",
job::expand,
)
}
#[proc_macro_attribute]
pub fn workflow(args: TokenStream, input: TokenStream) -> TokenStream {
attribute(
args,
input,
"`#[workflow]` goes on the impl of a workflow struct, as in `#[workflow] impl OnboardUser { .. }`",
workflow::expand,
)
}
#[proc_macro_attribute]
pub fn job_middleware(args: TokenStream, input: TokenStream) -> TokenStream {
attribute(
args,
input,
"`#[middleware]` goes on an async function",
|NoArguments, function| job_middleware::expand(function),
)
}
#[proc_macro_attribute]
pub fn queue_callback(args: TokenStream, input: TokenStream) -> TokenStream {
attribute(
args,
input,
"`#[callback]` goes on an async function or an inherent impl",
queue_callback::expand_item,
)
}