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
impl MockRegistrar
Sourcepub fn scalar_names(&self) -> Vec<String>
pub fn scalar_names(&self) -> Vec<String>
Returns the names of all scalar functions registered so far.
Sourcepub fn scalar_set_names(&self) -> Vec<String>
pub fn scalar_set_names(&self) -> Vec<String>
Returns the names of all scalar function sets registered so far.
Sourcepub fn aggregate_names(&self) -> Vec<String>
pub fn aggregate_names(&self) -> Vec<String>
Returns the names of all aggregate functions registered so far.
Sourcepub fn aggregate_set_names(&self) -> Vec<String>
pub fn aggregate_set_names(&self) -> Vec<String>
Returns the names of all aggregate function sets registered so far.
Sourcepub fn table_names(&self) -> Vec<String>
pub fn table_names(&self) -> Vec<String>
Returns the names of all table functions registered so far.
Sourcepub fn sql_macro_names(&self) -> Vec<String>
pub fn sql_macro_names(&self) -> Vec<String>
Returns the names of all SQL macros registered so far.
Sourcepub fn casts(&self) -> Vec<CastRecord>
pub fn casts(&self) -> Vec<CastRecord>
Returns all cast registrations recorded so far.
Sourcepub fn copy_function_names(&self) -> Vec<String>
pub fn copy_function_names(&self) -> Vec<String>
Returns the names of all copy functions registered so far.
Sourcepub fn has_copy_function(&self, name: &str) -> bool
pub fn has_copy_function(&self, name: &str) -> bool
Returns true if a copy function with the given name was registered.
Sourcepub fn config_option_names(&self) -> Vec<String>
pub fn config_option_names(&self) -> Vec<String>
Returns the names of all config options registered so far.
Sourcepub fn has_config_option(&self, name: &str) -> bool
pub fn has_config_option(&self, name: &str) -> bool
Returns true if a config option with the given name was registered.
Sourcepub fn total_registrations(&self) -> usize
pub fn total_registrations(&self) -> usize
Returns the total number of registrations across all types.
Sourcepub fn has_scalar(&self, name: &str) -> bool
pub fn has_scalar(&self, name: &str) -> bool
Returns true if a scalar function with the given name was registered.
Sourcepub fn has_scalar_set(&self, name: &str) -> bool
pub fn has_scalar_set(&self, name: &str) -> bool
Returns true if a scalar function set with the given name was registered.
Sourcepub fn has_aggregate(&self, name: &str) -> bool
pub fn has_aggregate(&self, name: &str) -> bool
Returns true if an aggregate function with the given name was registered.
Sourcepub fn has_aggregate_set(&self, name: &str) -> bool
pub fn has_aggregate_set(&self, name: &str) -> bool
Returns true if an aggregate function set with the given name was registered.
Sourcepub fn has_table(&self, name: &str) -> bool
pub fn has_table(&self, name: &str) -> bool
Returns true if a table function with the given name was registered.
Sourcepub fn has_sql_macro(&self, name: &str) -> bool
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
impl Debug for MockRegistrar
Source§impl Default for MockRegistrar
impl Default for MockRegistrar
Source§fn default() -> MockRegistrar
fn default() -> MockRegistrar
Source§impl Registrar for MockRegistrar
impl Registrar for MockRegistrar
Source§unsafe fn register_scalar(
&self,
builder: ScalarFunctionBuilder,
) -> Result<(), ExtensionError>
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>
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>
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>
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>
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>
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>
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>
unsafe fn register_copy_function( &self, builder: CopyFunctionBuilder, ) -> Result<(), ExtensionError>
Source§unsafe fn register_config_option(
&self,
builder: ConfigOptionBuilder,
) -> Result<(), ExtensionError>
unsafe fn register_config_option( &self, builder: ConfigOptionBuilder, ) -> Result<(), ExtensionError>
Source§unsafe fn register_typed_scalar(
&self,
builder: TypedScalarFunctionBuilder,
) -> Result<(), ExtensionError>
unsafe fn register_typed_scalar( &self, builder: TypedScalarFunctionBuilder, ) -> Result<(), ExtensionError>
ScalarFunctionBuilder::map1 and friends). Read more