Skip to main content

Module prelude

Module prelude 

Source
Expand description

Convenience re-exports for the most commonly used quack-rs items.

This prelude covers the types and functions needed in the src/lib.rs of a typical DuckDB Rust extension. Import it with:

use quack_rs::prelude::*;

fn register(con: libduckdb_sys::duckdb_connection) -> Result<(), ExtensionError> {
    let _ = con;
    Ok(())
}

// The entry-point macros come with the glob import.
entry_point!(my_extension_init_c_api, |con| register(con));

§What is included

ItemFrom
init_extensionentry_point module
init_extension_v2entry_point module
entry_point!entry_point module (macro)
entry_point_v2!entry_point module (macro)
AbiPolicyabi module
Connectionconnection module
Registrarconnection module
CastFncast module
CastFunctionBuildercast module
CastFunctionInfocast module
CastModecast module
AggregateFunctionBuilderaggregate module
AggregateFunctionInfoaggregate module
AggregateFunctionSetBuilderaggregate module
AggregateOverloadBuilderaggregate module
AggregateStateaggregate module
FfiStateaggregate module
ScalarFunctionBuilderscalar module
ScalarFunctionInfoscalar module
ScalarFunctionSetBuilderscalar module
ScalarOverloadBuilderscalar module
TypedScalarFunctionBuilderscalar module
TableFunctionBuildertable module
TypedTableFunctionBuildertable module
BindInfotable module
InitInfotable module
FunctionInfotable module
FfiBindDatatable module
FfiInitDatatable module
FfiLocalInitDatatable module
ReplacementScanBuilderreplacement_scan module
ReplacementScanInforeplacement_scan module
SqlMacrosql_macro module
ChunkWriterchunk_writer module
DataChunkdata_chunk module
Valuevalue module
VectorReadervector module
VectorWritervector module
ListBuildervector module
ValidityBitmapvector::validity module
ArrayVectorvector::complex module
StructReadervector::struct_reader module
StructWritervector::struct_writer module
StructVectorvector::complex module
ListVectorvector::complex module
MapVectorvector::complex module
TypeIdtypes module
LogicalTypetypes module
NullHandlingtypes module
DuckIntervalinterval module
interval_to_microsinterval module
Date / Time / TimeTz / Timestampdatetime module
OwnedConnection / OwnedDataChunk / PreparedStatement / QueryResultquery module
ExtensionErrorerror module
ExtResulterror module
SecretEntrysecrets module
SecretsManagersecrets module
TlsConfigProvidertls module
TlsVersiontls module
audit_tls_providertls module
ExtensionWarningwarning module
WarningCollectorwarning module
WarningSeveritywarning module
DUCKDB_API_VERSIONcrate root
DUCKDB_API_VERSION_1_5_6crate root
Appenderappender module

§DuckDB 1.5.0+ items (require the duckdb-1-5 feature)

ItemFrom
ScalarBindInfo / ScalarInitInfoscalar module
ScalarBindData / ScalarLocalStatescalar module
CopyFunctionBuilder and its callback types: CopyBindFn / CopyBindInfo, CopyGlobalInitFn / CopyGlobalInitInfo, CopySinkFn / CopySinkInfo, CopyFinalizeFn / CopyFinalizeInfocopy_function module
ErrorData / DuckDbErrorTypeerror_data module
Expressionexpression module
FileSystem / FileHandle / FileOpenOptions / FileFlagfile_system module
SelectionVectorselection_vector module
InstanceCacheinstance_cache module

§What is NOT included

The following items are intentionally excluded from the prelude because they are used less frequently and benefit from explicit import paths:

  • crate::config::DbConfig — RAII wrapper for opening secondary DuckDB databases; import explicitly via use quack_rs::config::DbConfig when needed
  • validate::* — validation utilities (use explicitly to make intent clear)
  • scaffold::* — project generation (use explicitly)
  • testing::* — test harness (typically imported only in #[cfg(test)])
  • interval::read_interval_at — low-level; use VectorReader::read_interval instead

§Example

use quack_rs::prelude::*;

// Your state struct
#[derive(Default)]
struct MyState { count: i64 }
impl AggregateState for MyState {}

// Registration (called from your entry point)
fn register(con: libduckdb_sys::duckdb_connection) -> ExtResult<()> {
    let _ = AggregateFunctionBuilder::try_new("my_count")?
        .param(TypeId::BigInt)
        .returns(TypeId::BigInt)
        .ffi_state::<MyState>()
        // ... callbacks ...
        ;
    Ok(())
}

Re-exports§

pub use crate::entry_point::init_extension;
pub use crate::entry_point::init_extension_v2;
pub use crate::abi::AbiPolicy;
pub use crate::connection::Connection;
pub use crate::connection::Registrar;
pub use crate::cast::CastFn;
pub use crate::cast::CastFunctionBuilder;
pub use crate::cast::CastFunctionInfo;
pub use crate::cast::CastMode;
pub use crate::aggregate::AggregateFunctionBuilder;
pub use crate::aggregate::AggregateFunctionInfo;
pub use crate::aggregate::AggregateFunctionSetBuilder;
pub use crate::aggregate::AggregateOverloadBuilder;
pub use crate::aggregate::AggregateState;
pub use crate::aggregate::FfiState;
pub use crate::scalar::ScalarBindData;
pub use crate::scalar::ScalarBindInfo;
pub use crate::scalar::ScalarInitInfo;
pub use crate::scalar::ScalarLocalState;
pub use crate::scalar::ScalarFunctionBuilder;
pub use crate::scalar::ScalarFunctionInfo;
pub use crate::scalar::ScalarFunctionSetBuilder;
pub use crate::scalar::ScalarOverloadBuilder;
pub use crate::scalar::TypedScalarFunctionBuilder;
pub use crate::copy_function::CopyBindFn;
pub use crate::copy_function::CopyBindInfo;
pub use crate::copy_function::CopyFinalizeFn;
pub use crate::copy_function::CopyFinalizeInfo;
pub use crate::copy_function::CopyFunctionBuilder;
pub use crate::copy_function::CopyGlobalInitFn;
pub use crate::copy_function::CopyGlobalInitInfo;
pub use crate::copy_function::CopySinkFn;
pub use crate::copy_function::CopySinkInfo;
pub use crate::appender::Appender;
pub use crate::error_data::DuckDbErrorType;
pub use crate::error_data::ErrorData;
pub use crate::expression::Expression;
pub use crate::file_system::FileFlag;
pub use crate::file_system::FileHandle;
pub use crate::file_system::FileOpenOptions;
pub use crate::file_system::FileSystem;
pub use crate::instance_cache::InstanceCache;
pub use crate::selection_vector::SelectionVector;
pub use crate::table::BindInfo;
pub use crate::table::FfiBindData;
pub use crate::table::FfiInitData;
pub use crate::table::FfiLocalInitData;
pub use crate::table::FunctionInfo;
pub use crate::table::InitInfo;
pub use crate::table::TableFunctionBuilder;
pub use crate::table::TypedTableFunctionBuilder;
pub use crate::replacement_scan::ReplacementScanBuilder;
pub use crate::replacement_scan::ReplacementScanInfo;
pub use crate::sql_macro::SqlMacro;
pub use crate::chunk_writer::ChunkWriter;
pub use crate::data_chunk::DataChunk;
pub use crate::value::Value;
pub use crate::vector::complex::ArrayVector;
pub use crate::vector::complex::ListVector;
pub use crate::vector::complex::MapVector;
pub use crate::vector::complex::StructVector;
pub use crate::vector::ListBuilder;
pub use crate::vector::StructReader;
pub use crate::vector::StructWriter;
pub use crate::vector::ValidityBitmap;
pub use crate::vector::VectorReader;
pub use crate::vector::VectorWriter;
pub use crate::types::LogicalType;
pub use crate::types::NullHandling;
pub use crate::types::TypeId;
pub use crate::interval::interval_to_micros;
pub use crate::interval::DuckInterval;
pub use crate::datetime::Date;
pub use crate::datetime::Time;
pub use crate::datetime::TimeTz;
pub use crate::datetime::Timestamp;
pub use crate::query::OwnedConnection;
pub use crate::query::OwnedDataChunk;
pub use crate::query::PreparedStatement;
pub use crate::query::QueryResult;
pub use crate::error::ExtResult;
pub use crate::error::ExtensionError;
pub use crate::secrets::SecretEntry;
pub use crate::secrets::SecretsManager;
pub use crate::tls::audit_tls_provider;
pub use crate::tls::TlsConfigProvider;
pub use crate::tls::TlsVersion;
pub use crate::warning::ExtensionWarning;
pub use crate::warning::WarningCollector;
pub use crate::warning::WarningSeverity;
pub use crate::DUCKDB_API_VERSION;
pub use crate::DUCKDB_API_VERSION_1_5_6;
pub use crate::entry_point;
pub use crate::entry_point;

Macros§

entry_point
Generates the #[unsafe(no_mangle)] unsafe extern "C" entry point for a DuckDB extension.
entry_point_v2
Generates the #[unsafe(no_mangle)] unsafe extern "C" entry point using the version-agnostic Connection facade.