Skip to main content

ReplacementScanBuilder

Struct ReplacementScanBuilder 

Source
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

Source

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 valid duckdb_database. Obtain this via access.get_database(info) in the extension entry point.
  • callback — your replacement scan function.
  • extra_data — user data passed as the third argument to callback. Pass std::ptr::null_mut() if you need no extra data.
  • delete_callback — called by DuckDB with extra_data when the replacement scan is removed (e.g., database closed). Pass None if extra_data needs no special cleanup. Unlike DuckDB’s other destructor slots, it is called even when extra_data is null.
§Safety
  • db must be a valid, open duckdb_database.
  • extra_data must remain valid until delete_callback is called (or until the database is closed if delete_callback is None).
  • delete_callback, if set, must accept a null argument when extra_data is null.
  • extra_data must be safe to share between threads: DuckDB passes it to callback from any connection’s thread, concurrently, and calls delete_callback from whichever thread closes the database. Treat it as &T where T: Send + Sync.
Source

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.

Trait Implementations§

Source§

impl Debug for ReplacementScanBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.