Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/nimdeveloper/better-duck/llms.txt

Use this file to discover all available pages before exploring further.

Cargo feature flags let you opt in to optional capabilities without pulling in dependencies you don’t need. better-duck uses feature flags extensively because it targets a wide range of environments — from Tauri desktop apps and iOS cross-builds to server-side async services and data-pipeline tools — and because some of its optional dependencies (like tokio or chrono) are large enough that you may want to exclude them. This page lists every feature flag for both better-duck-core and better-duck-diesel, explains what each one enables, and notes which are on by default.

better-duck-core Features

The better-duck-core crate is the low-level DuckDB wrapper. Its feature flags control date/time conversions, decimal support, extensions, async, pooling, and user-defined functions.
FeatureDefaultDescription
chronoEnable chrono date/time conversions for DATE, TIME, TIMESTAMP, TIMESTAMPTZ, TIME_TZ, TIME_NS, and INTERVAL. When enabled, temporal DuckValue variants carry chrono types. When disabled, they carry types from better_duck_core::types::date_native and std::time.
decimalEnable rust_decimal::Decimal support for DECIMAL columns. Adds the DuckValue::Decimal variant and impl AppendAble for Decimal.
jsonEnable DuckDB’s JSON extension. Needed only if you use json_extract, to_json, or other JSON functions in your queries.
parquetEnable DuckDB’s Parquet extension. Needed only if you use read_parquet(…) or other Parquet functions in your queries.
asyncTokio-based async facade over spawn_blocking: adds AsyncConnection, AsyncDatabase, and AsyncPool. These types never block the async executor. Requires tokio with the rt feature.
poolr2d2 connection pool backed by a shared Database handle. Adds DuckDbConnectionManager and re-exports r2d2::Pool. Unlike opening N independent connections, every pooled connection shares the same underlying database, which is important for in-memory databases.
udf#[duckdb_scalar] and #[duckdb_table_function] proc-macro attributes for registering plain Rust functions as DuckDB scalar or table functions. Adds the better-duck-macros proc-macro crate as a dependency.

better-duck-diesel Features

The better-duck-diesel crate is the Diesel 2.3 backend. Its feature flags are a smaller set — they mainly control whether optional chrono and decimal support flows through from better-duck-core, and whether r2d2 pooling is exposed via Diesel’s own ConnectionManager.
FeatureDefaultDescription
decimalEnable Diesel Numericrust_decimal::Decimal mapping. Activates better-duck-core/decimal and the rust_decimal dependency.
chronoEnable Diesel FromSql/ToSql impls for DATE, TIME, TIMESTAMP, TIMESTAMPTZ, INTERVAL, TIME_TZ, and TIME_NS. Activates better-duck-core/chrono, diesel/chrono, and the chrono dependency.
r2d2r2d2 connection pool support via Diesel’s own diesel::r2d2::ConnectionManager<DuckDbConnection>. Activates diesel/r2d2.
The chrono feature is on by default in better-duck-core but off by default in better-duck-diesel. If you are using better-duck-diesel with Diesel date/time columns, you must explicitly enable chrono in your Cargo.toml dependency on better-duck-diesel. The reason for the asymmetry is that many Diesel users already pull chrono in through Diesel’s own feature system and want explicit control over which backend enables it.

Enabling Features in Cargo.toml

Add better-duck-core or better-duck-diesel to your [dependencies] section and list the features you need. Because these crates are currently in pre-release, you must pin the full version string — Cargo’s default version requirement ("0.1") excludes pre-release versions.
# Enable async and pool for better-duck-core
[dependencies]
better-duck-core = { version = "0.1.0-beta.4", features = ["async", "pool"] }
# Enable UDF support
[dependencies]
better-duck-core = { version = "0.1.0-beta.4", features = ["udf"] }
# Enable chrono and r2d2 for the Diesel backend
[dependencies]
better-duck-core   = "0.1.0-beta.4"
better-duck-diesel = { version = "0.1.0-beta.4", features = ["chrono", "r2d2"] }
# Disable default features (chrono and decimal) for a minimal build
[dependencies]
better-duck-core = { version = "0.1.0-beta.4", default-features = false }
Enable the json and parquet features only if you actually use DuckDB’s JSON or Parquet extensions in your queries. Both add meaningful compile-time cost. If your workload is purely relational, leave them disabled.

Date/Time Without chrono

When the chrono feature is disabled, all temporal DuckValue variants and AppendAble impls use types from better_duck_core::types::date_native instead of chrono types. The native types are lightweight plain structs with no external dependencies:
DuckDB typeNo-chrono Rust typeFields
DATEDuckDateyear: i32, month: u8, day: u8
TIMEDuckTimehour: u8, min: u8, sec: u8, micros: u32
TIME_NSDuckTimeNshour: u8, min: u8, sec: u8, nanos: u32
TIME WITH TIME ZONEDuckTimeTzhour, min, sec, micros, offset_secs: i32
TIMESTAMP / TIMESTAMPTZstd::time::SystemTime
INTERVALstd::time::Duration
Only one set of implementations is compiled at a time — there is no runtime switching between chrono and native types. The decision is made at compile time by the presence or absence of the chrono feature.
// With `chrono` disabled, date columns yield DuckDate
#[cfg(not(feature = "chrono"))]
use better_duck_core::types::date_native::DuckDate;

match value {
    DuckValue::Date(d) => println!("{}-{:02}-{:02}", d.year, d.month, d.day),
    DuckValue::Time(t) => println!("{:02}:{:02}:{:02}", t.hour, t.min, t.sec),
    DuckValue::Null    => println!("null"),
    _ => {}
}
For better-duck-diesel specifically, remember that the chrono feature must be enabled explicitly — see the note in the better-duck-diesel Features section above.

Build docs developers (and LLMs) love