Skip to main content

ScalarInitInfo

Struct ScalarInitInfo 

Source
pub struct ScalarInitInfo { /* private fields */ }
Expand description

Ergonomic wrapper around the duckdb_init_info handle provided to a scalar function init callback (DuckDB 1.5.0+).

Provides access to extra info, bind data, per-thread state storage, and error reporting.

Implementations§

Source§

impl ScalarInitInfo

Source

pub const unsafe fn new(info: RawScalarInitInfo) -> Self

Wraps the info DuckDB passes to a scalar function init callback.

Breaking in 0.18.0: takes a RawScalarInitInfo, the argument type of ScalarInitFn, not a bare duckdb_init_info.

§Safety

info must be the argument DuckDB passed to a scalar function init callback that is still running.

Source

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.

Source

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.

Source

pub unsafe fn set_state( &self, state: *mut c_void, destroy: duckdb_delete_callback_t, )

Stores per-thread state that can later be retrieved during execution via ScalarFunctionInfo::get_state.

A second call overwrites the pointer and destructor without running the first destructor: the first value is leaked.

§Safety

state must point to valid memory. destroy will be called by DuckDB to free the state when the thread finishes. The typical pattern is to box your data: Box::into_raw(Box::new(my_state)).cast().

Source

pub fn set_error(&self, message: &str)

Reports an error from the scalar function init 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.

Source

pub unsafe fn get_client_context(&self) -> ClientContext

Returns the client context for this callback.

The returned ClientContext provides access to the connection’s catalog, configuration, and connection ID.

§Safety

The inner handle must be valid (requires DuckDB runtime), and the returned context must not be used after the connection running this query is closed — see ClientContext.

Source

pub const fn as_raw(&self) -> duckdb_init_info

Returns the raw duckdb_init_info handle.

Trait Implementations§

Source§

impl Debug for ScalarInitInfo

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.