better_duck_core/lib.rs
1// SPDX-License-Identifier: MIT OR Apache-2.0
2//! `better-duck-core` — a safe, low-level Rust wrapper around the
3//! [DuckDB](https://duckdb.org) C API (`libduckdb-sys`).
4//!
5//! This crate provides:
6//! - A high-level [`connection::Connection`] for opening databases and executing SQL.
7//! - Low-level raw types (`RawConnection`, `DuckResult`, `DuckRow`) for advanced use.
8//! - Type conversion traits ([`types::DuckDialect`], [`types::appendable::AppendAble`]) for
9//! mapping between Rust types and DuckDB values.
10
11pub extern crate libduckdb_sys;
12/// Re-export of the raw `libduckdb_sys` FFI bindings.
13pub use libduckdb_sys as ffi;
14
15/// Async facade over [`connection::Connection`], gated by the `async` feature.
16#[cfg(feature = "async")]
17pub mod asynchronous;
18/// DuckDB database configuration.
19pub mod config;
20/// High-level DuckDB connection type.
21pub mod connection;
22/// A shared, cloneable handle to an open DuckDB database.
23pub mod database;
24/// Error types returned by this crate.
25pub mod error;
26mod helpers;
27/// An `r2d2` connection pool backed by a shared [`Database`](database::Database).
28#[cfg(feature = "pool")]
29pub mod pool;
30mod raw;
31/// An owned, thread-safe, fully materialized query result.
32pub mod result_set;
33/// DuckDB type system and value conversion traits.
34pub mod types;
35/// User-defined DuckDB functions: scalar functions and table functions.
36#[cfg(feature = "udf")]
37pub mod udf;
38
39/// Async facade over [`connection::Connection`].
40#[cfg(feature = "async")]
41pub use asynchronous::AsyncConnection;
42/// Async facade over [`Database`].
43#[cfg(feature = "async")]
44pub use asynchronous::AsyncDatabase;
45/// Async facade over [`pool::Pool`].
46#[cfg(all(feature = "async", feature = "pool"))]
47pub use asynchronous::AsyncPool;
48
49/// Registers a plain Rust function as a DuckDB scalar function. See [`udf`].
50#[cfg(feature = "udf")]
51pub use better_duck_macros::duckdb_scalar;
52/// Registers a plain Rust function as a DuckDB table function. See [`udf`].
53#[cfg(feature = "udf")]
54pub use better_duck_macros::duckdb_table_function;
55/// DuckDB database configuration.
56pub use config::{AccessMode, Config, DefaultNullOrder, DefaultOrder};
57/// A shared, cloneable handle to an open DuckDB database.
58pub use database::Database;
59/// A DuckDB appender for bulk-inserting rows into a table.
60pub use raw::appender::Appender;
61/// A fully iterable DuckDB query result.
62pub use raw::result::DuckResult;
63/// A single row from a DuckDB query result.
64pub use raw::row::DuckRow;
65/// A prepared statement suitable for caching and re-execution.
66pub use raw::statement::CachedStatement;
67/// An owned, thread-safe, fully materialized query result.
68pub use result_set::ResultSet;
69/// Trait for binding values to DuckDB prepared statements and appenders.
70pub use types::appendable::AppendAble;
71/// A calendar date value for use without the `chrono` feature.
72#[cfg(not(feature = "chrono"))]
73pub use types::date_native::DuckDate;
74/// A time-of-day value for use without the `chrono` feature.
75#[cfg(not(feature = "chrono"))]
76pub use types::date_native::DuckTime;