macro_rules! table_scan_callback {
($name:ident, |$info:ident, $output:ident| $body:block) => { ... };
}Expand description
Generates a panic-safe unsafe extern "C" table function scan callback.
The macro emits a function with signature:
unsafe extern "C" fn $name(
info: duckdb_function_info,
output: duckdb_data_chunk,
)The body is wrapped in std::panic::catch_unwind. If the closure panics,
the output chunk size is set to 0 (signaling end of stream) to prevent
undefined behaviour from unwinding across the FFI boundary.
§Parameters
$name— the name of the generated function$body— a closure with signature|info: duckdb_function_info, output: duckdb_data_chunk|
§Example
quack_rs::table_scan_callback!(my_scan, |info, output| {
let chunk = unsafe { quack_rs::data_chunk::DataChunk::from_raw(output) };
let mut writer = unsafe { chunk.writer(0) };
unsafe { writer.write_i64(0, 42) };
unsafe { chunk.set_size(1) };
});