macro_rules! export_task {
(
task_type = $task:expr,
sheet_name = $sheet:expr,
headers = $headers:expr,
rows = $rows:expr
$(,)?
) => { ... };
(
task_type = $task:expr,
mime = $mime:expr,
file = $file:expr
$(,)?
) => { ... };
}Expand description
注册一个异步导出任务(唯一宏:行导出 / 文件导出都用它)。
展开后直接向 inventory 提交任务定义,链接期即完成注册:
没有执行器结构体、没有 install()、不需要在 main.rs 聚合。
导出中心按 task_type 查到函数后直接调用。
§形态一:行数据导出(业务只查数据,引擎写 xlsx)
ⓘ
fast_excel::export_task! {
task_type = "factory",
sheet_name = "工厂数据",
headers = FACTORY_HEADERS,
rows = factory_export_rows, // async fn(ExportTaskContext) -> Result<Vec<Vec<String>>, E>
}§形态二:文件导出(业务自带流式生成,如带图 xlsx)
ⓘ
fast_excel::export_task! {
task_type = "product",
mime = fast_excel::XLSX_MIME,
file = product_export_file, // async fn(ExportTaskContext) -> Result<(i64, String), E>
}rows / file 也接受非捕获闭包(如 |ctx| rows_for(kind, ctx)),
方便一个模块用同一份逻辑注册多张表。