Skip to main content

ScalarFunctionInfo

Struct ScalarFunctionInfo 

Source
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

Source

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.

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 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.

Source

pub const fn as_raw(&self) -> duckdb_function_info

Returns the raw duckdb_function_info handle.

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 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.

Trait Implementations§

Source§

impl Debug for ScalarFunctionInfo

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.