Expand description
better-duck-core — a safe, low-level Rust wrapper around the
DuckDB C API (vendored in-workspace via better-duck-sys).
This crate provides:
- A high-level
connection::Connectionfor opening databases and executing SQL. - Low-level raw types (
RawConnection,DuckResult,DuckRow) for advanced use. - Type conversion traits (
types::DuckDialect,types::appendable::AppendAble) for mapping between Rust types and DuckDB values.
Re-exports§
pub extern crate better_duck_sys as libduckdb_sys;
Re-exports§
pub use asynchronous::AsyncConnection;pub use asynchronous::AsyncDatabase;pub use asynchronous::AsyncPool;pub use config::library_version;pub use config::AccessMode;pub use config::Config;pub use config::ConfigFlag;pub use config::DefaultNullOrder;pub use config::DefaultOrder;pub use database::Database;pub use types::convert::double_to_hugeint;pub use types::convert::double_to_uhugeint;pub use types::convert::hugeint_to_double;pub use types::convert::parts_to_timestamp_micros;pub use types::convert::timestamp_micros_to_parts;pub use types::convert::uhugeint_to_double;pub use types::convert::TimestampParts;pub use result_set::ResultSet;pub use types::appendable::AppendAble;pub use better_duck_sys as ffi;
Modules§
- asynchronous
- Async facade over
connection::Connection, gated by theasyncfeature. Async facade overConnection, gated by theasyncfeature. - config
- DuckDB database configuration.
- connection
- High-level DuckDB connection type.
- database
- A shared, cloneable handle to an open DuckDB database.
- error
- Error types returned by this crate.
- pool
- An
r2d2connection pool backed by a sharedDatabase. Anr2d2connection pool backed by a sharedDatabase. - result_
set - An owned, thread-safe, fully materialized query result.
- types
- DuckDB type system and value conversion traits.
- udf
- User-defined DuckDB functions: scalar functions and table functions. User-defined DuckDB functions: scalar functions and table functions.
Macros§
- duck_
bail - Returns early from a fallible user-defined-function body with a formatted error message.
- duck_
extra_ info - Returns a clone of the current table function’s registration-time “extra
info” (see
Connection::register_table_function_with_extra_info), from inside a#[duckdb_table_function]function body. - duck_
projection - Returns the 0-based column indices the current query actually needs, as a
Vec<usize>, from inside a#[duckdb_table_function(projection_pushdown)]function body. - duck_
state - Returns a clone of the current scalar function’s
State, from inside a#[duckdb_scalar(state = ...)]function body. - impl_
appendable_ via_ to_ duck_ native - Implements
AppendAblefor a type that already implementscrate::types::DuckDialectby going through theduckdb_valuepath:to_duck()→duckdb_bind_value/duckdb_append_value→duckdb_destroy_value.
Structs§
- Appender
- A DuckDB appender for bulk-inserting rows into a table. A DuckDB appender for bulk-inserting rows into a table without going through the SQL parser.
- Cached
Statement - A prepared statement suitable for caching and re-execution. A prepared statement that can be reset and re-executed with different bindings.
- Client
Context - An owned
duckdb_client_context, borrow-tied to the owner it came from so it cannot outlive it. - Data
Chunk - An owned DuckDB
duckdb_data_chunk— a batch of column vectors — that is destroyed on drop. - Duck
Result - A fully iterable DuckDB query result. Represents the result of a DuckDB query, providing row-by-row iteration over the returned data.
- DuckRow
- A single row from a DuckDB query result. A single row of data returned by a DuckDB query, consisting of typed values and their associated column names.
- Expression
- An owned, bound
duckdb_expression(destroyed once on drop). - Extracted
Statements - A parsed batch of SQL statements, each preparable on demand. A parsed batch of SQL statements, each preparable on demand.
- Instance
Cache - An owned
duckdb_instance_cache(destroyed once on drop). - Interval
Parts - A broken-down DuckDB
INTERVAL(months, days, microseconds). - Owned
Pending - Incremental execution of a prepared statement, one task at a time.
An owned pending execution: like
PendingResultbut it owns itsCachedStatementinstead of borrowing one, so it carries no lifetime and is'static. - Owned
Value - An owned standalone
duckdb_value(destroyed once on drop) with introspection. - Owned
Vector - An owned standalone
duckdb_vector(destroyed once on drop). - Pending
Result - Incremental execution of a prepared statement, one task at a time. A pending (incrementally-executed) query, borrowing the statement it runs.
- Profiling
Node - An owned node of the query-profiling tree: the metrics recorded at this node (name → value, both strings) plus its child nodes, in DuckDB’s order.
- Query
Control - A thread-safe handle for interrupting or observing one running query. A narrow, thread-safe handle for interrupting or observing one query.
- Query
Progress - A thread-safe handle for interrupting or observing one running query. A snapshot of a running query’s progress.
- Selection
Vector - An owned
duckdb_selection_vectorofsizeu32indices. - Table
Description - An owned
duckdb_table_descriptionwith indexed column-name/default access. - Task
State - An owned
duckdb_task_statethat drives a database’s task execution.
Enums§
- Pending
State - Incremental execution of a prepared statement, one task at a time. The state of a pending execution, as reported by DuckDB.
- Result
Type - A fully iterable DuckDB query result. What kind of output a query produced.
- Statement
Type - A prepared statement suitable for caching and re-execution. The kind of SQL statement a prepared statement holds.
Functions§
- execute_
tasks - Runs up to
max_tasksof a database’s pending tasks on the calling thread, once.
Attribute Macros§
- duckdb_
scalar - Registers a plain Rust function as a DuckDB scalar function. See
udf. Registers a plain Rust function as a DuckDB scalar function. - duckdb_
table_ function - Registers a plain Rust function as a DuckDB table function. See
udf. Registers a plain Rust function as a DuckDB table function.