Skip to main content

Crate better_duck_core

Crate better_duck_core 

Source
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:

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 the async feature. Async facade over Connection, gated by the async feature.
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 r2d2 connection pool backed by a shared Database. An r2d2 connection pool backed by a shared Database.
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 AppendAble for a type that already implements crate::types::DuckDialect by going through the duckdb_value path: 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.
CachedStatement
A prepared statement suitable for caching and re-execution. A prepared statement that can be reset and re-executed with different bindings.
ClientContext
An owned duckdb_client_context, borrow-tied to the owner it came from so it cannot outlive it.
DataChunk
An owned DuckDB duckdb_data_chunk — a batch of column vectors — that is destroyed on drop.
DuckResult
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).
ExtractedStatements
A parsed batch of SQL statements, each preparable on demand. A parsed batch of SQL statements, each preparable on demand.
InstanceCache
An owned duckdb_instance_cache (destroyed once on drop).
IntervalParts
A broken-down DuckDB INTERVAL (months, days, microseconds).
OwnedPending
Incremental execution of a prepared statement, one task at a time. An owned pending execution: like PendingResult but it owns its CachedStatement instead of borrowing one, so it carries no lifetime and is 'static.
OwnedValue
An owned standalone duckdb_value (destroyed once on drop) with introspection.
OwnedVector
An owned standalone duckdb_vector (destroyed once on drop).
PendingResult
Incremental execution of a prepared statement, one task at a time. A pending (incrementally-executed) query, borrowing the statement it runs.
ProfilingNode
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.
QueryControl
A thread-safe handle for interrupting or observing one running query. A narrow, thread-safe handle for interrupting or observing one query.
QueryProgress
A thread-safe handle for interrupting or observing one running query. A snapshot of a running query’s progress.
SelectionVector
An owned duckdb_selection_vector of size u32 indices.
TableDescription
An owned duckdb_table_description with indexed column-name/default access.
TaskState
An owned duckdb_task_state that drives a database’s task execution.

Enums§

PendingState
Incremental execution of a prepared statement, one task at a time. The state of a pending execution, as reported by DuckDB.
ResultType
A fully iterable DuckDB query result. What kind of output a query produced.
StatementType
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_tasks of 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.