Expand description
duckfn-macro:duckfn 的过程宏实现。
本 crate 提供属性宏、derive 宏和函数式宏,把一个普通的 Rust 函数/结构体包装成
可注册到 DuckDB 的扩展对象;运行时依赖在 duckfn crate 中。
duckfn-macro: the procedural macros behind duckfn. This crate provides the attribute,
derive and function-like macros that wrap an ordinary Rust function or struct into an object
registerable with DuckDB; the runtime lives in the duckfn crate.
Macros§
- duck_
sql_ macro_ files - 一次注册多个 SQL 脚本文件(快捷方式)。
- duckfn_
entrypoint - Generate DuckDB extension entry point.
Attribute Macros§
- duck_
aggregate_ function - 把普通 Rust 函数注册成 DuckDB 聚合函数。
- duck_
cast_ function - 把
fn(源值) -> 目标值注册成 DuckDB 的 cast 函数,覆盖CAST(源 AS 目标)。 - duck_
copy_ from_ function - 把「按批取行」的 Rust 函数注册成 DuckDB 的 COPY 读取格式,为
COPY ... FROM提供自定义文件格式。 - duck_
copy_ function - 把「按批写行」的 Rust 函数注册成 DuckDB 的 COPY 函数,为
COPY ... TO提供自定义文件格式。 - duck_
custom_ register - 手动注册入口:把
fn(&Connection) -> DuckResult<()>交给扩展初始化时调用。 - duck_
replacement_ scan - 把
SELECT * FROM 'data.myformat'这类「未知表名/文件路径」重定向到某个表函数。 - duck_
scalar_ function - 把普通 Rust 函数注册成 DuckDB 标量函数。
- duck_
sql_ macro - 注册一个 SQL 宏:函数返回 SQL 文本(或 builder),扩展初始化时执行/注册。
- duck_
table_ function - 把返回迭代器的 Rust 函数注册成 DuckDB 表函数。
Derive Macros§
- Duck
Enum - 把「只有单元变体的 Rust enum」映射成 DuckDB
ENUM。 - Duck
Struct - 把一个具名结构体映射成 DuckDB
STRUCT(嵌套 LIST / MAP / ARRAY / STRUCT 均支持)。