#[task]Expand description
Registers a function as a unit task handler.
Unit tasks are async operations that execute once and complete. The function
must accept Site and a deserializable input type, returning a TaskUnitOutput.
§Attributes
name- Optional task name (defaults to function name)
§Examples
ⓘ
// Free function with default name
#[task]
async fn send_email(site: Site, input: EmailData) -> Result<TaskUnitOutput, TaskError> {
// send email
}
// Method with custom name
impl TaskHandlers {
#[task(name = "custom_task_name")]
async fn process_order(site: Site, order: Order) -> Result<TaskUnitOutput, TaskError> {
// process order
}
}