pub struct Connection { /* private fields */ }Expand description
Wraps the duckdb_connection and duckdb_database provided to your
extension at load time.
Connection implements Registrar, offering a single, uniform API for
registering all extension components. It also exposes
register_replacement_scan and
register_replacement_scan_with_data,
which require the duckdb_database handle and therefore cannot be part of
the Registrar trait.
§Obtaining a Connection
Use init_extension_v2 (or the
entry_point_v2! macro). Both pass a &Connection
to your registration callback.
§Version compatibility
Connection provides a uniform API across DuckDB 1.4.x and 1.5.x.
When future DuckDB releases add new C API surface, additional methods will
be gated on the corresponding feature flag.
Implementations§
Source§impl Connection
impl Connection
Sourcepub const fn as_raw_connection(&self) -> duckdb_connection
pub const fn as_raw_connection(&self) -> duckdb_connection
Return the raw duckdb_connection handle.
Use this to call C API functions that quack-rs does not yet wrap.
Sourcepub const fn as_raw_database(&self) -> duckdb_database
pub const fn as_raw_database(&self) -> duckdb_database
Return the raw duckdb_database handle.
Use this to call C API functions that require the database handle, such
as replacement scan registration or (with duckdb-1-5) config option
registration.
Sourcepub unsafe fn register_replacement_scan(
&self,
callback: ReplacementScanFn,
extra_data: *mut c_void,
delete_callback: duckdb_delete_callback_t,
)
pub unsafe fn register_replacement_scan( &self, callback: ReplacementScanFn, extra_data: *mut c_void, delete_callback: duckdb_delete_callback_t, )
Register a replacement scan backed by a raw function pointer and extra data.
For the ergonomic owned-data variant, see
register_replacement_scan_with_data.
§Safety
- The underlying
duckdb_databasemust be valid. extra_datamust remain valid untildelete_callbackis called (or until the database is closed ifdelete_callbackisNone).
Sourcepub unsafe fn register_replacement_scan_with_data<T: 'static>(
&self,
callback: ReplacementScanFn,
data: T,
)
pub unsafe fn register_replacement_scan_with_data<T: 'static>( &self, callback: ReplacementScanFn, data: T, )
Register a replacement scan with owned extra data.
Boxes data and registers a drop destructor automatically. This is the
safe, ergonomic alternative to
register_replacement_scan.
§Safety
The underlying duckdb_database must be valid.
Trait Implementations§
Source§impl Registrar for Connection
impl Registrar for Connection
Source§unsafe fn register_scalar(
&self,
builder: ScalarFunctionBuilder,
) -> Result<(), ExtensionError>
unsafe fn register_scalar( &self, builder: ScalarFunctionBuilder, ) -> Result<(), ExtensionError>
Source§unsafe fn register_scalar_set(
&self,
builder: ScalarFunctionSetBuilder,
) -> Result<(), ExtensionError>
unsafe fn register_scalar_set( &self, builder: ScalarFunctionSetBuilder, ) -> Result<(), ExtensionError>
Source§unsafe fn register_aggregate(
&self,
builder: AggregateFunctionBuilder,
) -> Result<(), ExtensionError>
unsafe fn register_aggregate( &self, builder: AggregateFunctionBuilder, ) -> Result<(), ExtensionError>
Source§unsafe fn register_aggregate_set(
&self,
builder: AggregateFunctionSetBuilder,
) -> Result<(), ExtensionError>
unsafe fn register_aggregate_set( &self, builder: AggregateFunctionSetBuilder, ) -> Result<(), ExtensionError>
Source§unsafe fn register_table(
&self,
builder: TableFunctionBuilder,
) -> Result<(), ExtensionError>
unsafe fn register_table( &self, builder: TableFunctionBuilder, ) -> Result<(), ExtensionError>
Source§unsafe fn register_sql_macro(
&self,
sql_macro: SqlMacro,
) -> Result<(), ExtensionError>
unsafe fn register_sql_macro( &self, sql_macro: SqlMacro, ) -> Result<(), ExtensionError>
SQL macro (scalar or table-returning). Read more