pub struct ReplacementScanBuilder;Expand description
Builder / registration helper for DuckDB replacement scans.
Unlike other builders in quack-rs, registration is a single static call because the replacement scan API takes a raw function pointer and optional extra data directly — there is no handle to configure step-by-step.
Implementations§
Source§impl ReplacementScanBuilder
impl ReplacementScanBuilder
Sourcepub unsafe fn register(
db: duckdb_database,
callback: ReplacementScanFn,
extra_data: *mut c_void,
delete_callback: duckdb_delete_callback_t,
)
pub unsafe fn register( db: duckdb_database, callback: ReplacementScanFn, extra_data: *mut c_void, delete_callback: duckdb_delete_callback_t, )
Registers a replacement scan callback on the given database.
§Arguments
db— a validduckdb_database. Obtain this viaaccess.get_database(info)in the extension entry point.callback— your replacement scan function.extra_data— user data passed as the third argument tocallback. Passstd::ptr::null_mut()if you need no extra data.delete_callback— called byDuckDBwithextra_datawhen the replacement scan is removed (e.g., database closed). PassNoneifextra_dataneeds no special cleanup. UnlikeDuckDB’s other destructor slots, it is called even whenextra_datais null.
§Safety
dbmust be a valid, openduckdb_database.extra_datamust remain valid untildelete_callbackis called (or until the database is closed ifdelete_callbackisNone).delete_callback, if set, must accept a null argument whenextra_datais null.extra_datamust be safe to share between threads:DuckDBpasses it tocallbackfrom any connection’s thread, concurrently, and callsdelete_callbackfrom whichever thread closes the database. Treat it as&TwhereT: Send + Sync.
Sourcepub unsafe fn register_with_data<T: Send + Sync + 'static>(
db: duckdb_database,
callback: ReplacementScanFn,
data: T,
)
pub unsafe fn register_with_data<T: Send + Sync + 'static>( db: duckdb_database, callback: ReplacementScanFn, data: T, )
Registers a replacement scan with owned extra data.
Boxes data and registers a drop destructor automatically.
This is the safe, ergonomic way to attach Rust data to a replacement scan.
T must be Send + Sync: the data lives in the database-wide
configuration, is handed (as &T behind the data pointer) to the
callback on whichever connection’s thread is binding a query — possibly
several at once — and is dropped on whichever thread closes the
database.
§Safety
db must be a valid, open duckdb_database.