pub struct ScalarFunctionInfo { /* private fields */ }Expand description
Ergonomic wrapper around the duckdb_function_info handle provided to a
scalar function callback.
Provides access to extra info and error reporting.
§Example
use quack_rs::scalar::ScalarFunctionInfo;
use libduckdb_sys::{duckdb_function_info, duckdb_data_chunk, duckdb_vector};
unsafe extern "C" fn my_func(
info: duckdb_function_info,
_input: duckdb_data_chunk,
_output: duckdb_vector,
) {
let info = unsafe { ScalarFunctionInfo::new(info) };
let _extra = unsafe { info.get_extra_info() };
// ... use extra info ...
}Implementations§
Source§impl ScalarFunctionInfo
impl ScalarFunctionInfo
Sourcepub const unsafe fn new(info: duckdb_function_info) -> Self
pub const unsafe fn new(info: duckdb_function_info) -> Self
Wraps a raw duckdb_function_info provided by DuckDB inside a scalar
function callback.
§Safety
info must be a valid duckdb_function_info passed by DuckDB to a
scalar function callback.
Sourcepub unsafe fn get_extra_info(&self) -> *mut c_void
pub unsafe fn get_extra_info(&self) -> *mut c_void
Retrieves the extra-info pointer previously set via
ScalarFunctionBuilder::extra_info.
Returns a raw *mut c_void. Cast it back to your concrete type.
§Safety
The returned pointer is only valid as long as the scalar function is
registered and DuckDB has not yet called the destructor.
Sourcepub fn set_error(&self, message: &str)
pub fn set_error(&self, message: &str)
Reports an error from the scalar function callback, causing DuckDB
to abort the current query.
An interior NUL byte in message is replaced with ?
(see message_to_c_string),
and an empty message by EMPTY_ERROR_PLACEHOLDER, since DuckDB
would otherwise report only an error-type prefix.
Sourcepub const fn as_raw(&self) -> duckdb_function_info
pub const fn as_raw(&self) -> duckdb_function_info
Returns the raw duckdb_function_info handle.
Sourcepub unsafe fn get_bind_data(&self) -> *mut c_void
pub unsafe fn get_bind_data(&self) -> *mut c_void
Retrieves the bind data pointer previously set via
ScalarBindInfo::set_bind_data during the bind callback.
Returns a raw *mut c_void. Cast it back to your concrete type.
§Safety
The returned pointer is only valid as long as DuckDB has not yet called
the destructor registered with ScalarBindInfo::set_bind_data.
Sourcepub unsafe fn get_state(&self) -> *mut c_void
pub unsafe fn get_state(&self) -> *mut c_void
Retrieves the per-thread state pointer previously set via
ScalarInitInfo::set_state during the init callback.
Returns a raw *mut c_void. Cast it back to your concrete type.
§Safety
The returned pointer is only valid as long as DuckDB has not yet called
the destructor registered with ScalarInitInfo::set_state.