Skip to main content

MockRegistrar

Struct MockRegistrar 

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

An in-memory mock implementation of Registrar for unit testing.

All register_* methods succeed silently (returning Ok(())) and record the function name (or types for casts). No DuckDB C API is called.

§Thread safety

MockRegistrar uses RefCell for interior mutability and is not Sync. Call it from a single thread within your tests.

Implementations§

Source§

impl MockRegistrar

Source

pub fn new() -> Self

Creates a new, empty MockRegistrar.

Source

pub fn scalar_names(&self) -> Vec<String>

Returns the names of all scalar functions registered so far.

Source

pub fn scalar_set_names(&self) -> Vec<String>

Returns the names of all scalar function sets registered so far.

Source

pub fn aggregate_names(&self) -> Vec<String>

Returns the names of all aggregate functions registered so far.

Source

pub fn aggregate_set_names(&self) -> Vec<String>

Returns the names of all aggregate function sets registered so far.

Source

pub fn table_names(&self) -> Vec<String>

Returns the names of all table functions registered so far.

Source

pub fn sql_macro_names(&self) -> Vec<String>

Returns the names of all SQL macros registered so far.

Source

pub fn casts(&self) -> Vec<CastRecord>

Returns all cast registrations recorded so far.

Source

pub fn copy_function_names(&self) -> Vec<String>

Returns the names of all copy functions registered so far.

Source

pub fn has_copy_function(&self, name: &str) -> bool

Returns true if a copy function with the given name was registered.

Source

pub fn config_option_names(&self) -> Vec<String>

Returns the names of all config options registered so far.

Source

pub fn has_config_option(&self, name: &str) -> bool

Returns true if a config option with the given name was registered.

Source

pub fn total_registrations(&self) -> usize

Returns the total number of registrations across all types.

Source

pub fn has_scalar(&self, name: &str) -> bool

Returns true if a scalar function with the given name was registered.

Source

pub fn has_scalar_set(&self, name: &str) -> bool

Returns true if a scalar function set with the given name was registered.

Source

pub fn has_aggregate(&self, name: &str) -> bool

Returns true if an aggregate function with the given name was registered.

Source

pub fn has_aggregate_set(&self, name: &str) -> bool

Returns true if an aggregate function set with the given name was registered.

Source

pub fn has_table(&self, name: &str) -> bool

Returns true if a table function with the given name was registered.

Source

pub fn has_sql_macro(&self, name: &str) -> bool

Returns true if a SQL macro with the given name was registered.

Trait Implementations§

Source§

impl Debug for MockRegistrar

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for MockRegistrar

Source§

fn default() -> MockRegistrar

Returns the “default value” for a type. Read more
Source§

impl Registrar for MockRegistrar

Source§

unsafe fn register_scalar( &self, builder: ScalarFunctionBuilder, ) -> Result<(), ExtensionError>

Records a scalar function registration. Never calls DuckDB C API.

§Safety

This implementation is safe to call in any context — no DuckDB connection is required.

Source§

unsafe fn register_scalar_set( &self, builder: ScalarFunctionSetBuilder, ) -> Result<(), ExtensionError>

Records a scalar function set registration. Never calls DuckDB C API.

§Safety

This implementation is safe to call in any context.

Source§

unsafe fn register_aggregate( &self, builder: AggregateFunctionBuilder, ) -> Result<(), ExtensionError>

Records an aggregate function registration. Never calls DuckDB C API.

§Safety

This implementation is safe to call in any context.

Source§

unsafe fn register_aggregate_set( &self, builder: AggregateFunctionSetBuilder, ) -> Result<(), ExtensionError>

Records an aggregate function set registration. Never calls DuckDB C API.

§Safety

This implementation is safe to call in any context.

Source§

unsafe fn register_table( &self, builder: TableFunctionBuilder, ) -> Result<(), ExtensionError>

Records a table function registration. Never calls DuckDB C API.

§Safety

This implementation is safe to call in any context.

Source§

unsafe fn register_sql_macro( &self, sql_macro: SqlMacro, ) -> Result<(), ExtensionError>

Records a SQL macro registration. Never calls DuckDB C API.

§Safety

This implementation is safe to call in any context.

Source§

unsafe fn register_cast( &self, builder: CastFunctionBuilder, ) -> Result<(), ExtensionError>

Records a cast function registration. Never calls DuckDB C API.

The source and target types are captured from the builder.

§Safety

This implementation is safe to call in any context.

Source§

unsafe fn register_copy_function( &self, builder: CopyFunctionBuilder, ) -> Result<(), ExtensionError>

Register a custom COPY TO function (DuckDB 1.5.0+). Read more
Source§

unsafe fn register_config_option( &self, builder: ConfigOptionBuilder, ) -> Result<(), ExtensionError>

Registers an extension-defined configuration option. Read more
Source§

unsafe fn register_typed_scalar( &self, builder: TypedScalarFunctionBuilder, ) -> Result<(), ExtensionError>

Register a scalar function built from a Rust closure (ScalarFunctionBuilder::map1 and friends). 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.