Skip to main content
Requires better-duck-core’s loadable-extension FFI mode (which implies udf). In that mode the crate links no DuckDB of its own and routes every FFI call through the host’s dynamically-loaded API table, building a cdylib. Re-exported as better_duck_core::duckdb_entrypoint.
#[duckdb_entrypoint] generates the C-ABI entrypoint DuckDB’s loader calls for a Rust-authored loadable extension (.duckdb_extension), wrapping a fn(&mut Connection) -> Result<…>.
The macro emits an exported my_ext_init_c_api symbol: it initializes the dynamically-loaded API table, obtains the host database, wraps it in a Connection via open_from_raw (which never closes the host-owned database), and invokes your init with &mut conn. An Err is reported back to DuckDB through the loader’s set_error.

Options

The generated code depends on the loadable-extension feature’s API-table initializer (better_duck_core::extension_api::c_api_init) and Connection::open_from_raw. Until built in that mode, code produced by this macro will not compile — the macro itself is stable groundwork.

See also