Expand description
Type-safe bind data management for table functions.
FfiBindData<T> stores user-defined data during the bind phase of a table
function and provides safe retrieval in the init and scan phases.
§DuckDB table function lifecycle
bind → stores bind_data (T)
init → reads bind_data to set up global state
local_init → reads bind_data to set up per-thread state (optional)
scan → reads bind_data + init_data + local_init_data, fills output chunk§Example
use quack_rs::table::FfiBindData;
use libduckdb_sys::{duckdb_bind_info, duckdb_function_info};
struct MyConfig { path: String }
unsafe extern "C" fn my_bind(info: duckdb_bind_info) {
// store bind data
unsafe { FfiBindData::<MyConfig>::set(info, MyConfig { path: "data.csv".into() }); }
}
unsafe extern "C" fn my_scan(info: duckdb_function_info, _output: libduckdb_sys::duckdb_data_chunk) {
// retrieve bind data in scan
if let Some(cfg) = unsafe { FfiBindData::<MyConfig>::get_from_function(info) } {
let _ = &cfg.path;
}
}Structs§
- FfiBind
Data - Type-safe bind data wrapper for
DuckDBtable functions.