These derives and helper macros come from
better-duck-core’s feature = "derive". Import them
from better_duck_core::… — you never depend on better-duck-macros directly.STRUCTs, and ENUMs, and two helper
macros smooth out transactions and parameter binding.
FromRow / ToRow
Read a query row into a struct; write a struct as an appender row or statement parameters.
DuckEnum
Map a Rust unit enum to a DuckDB
ENUM.DuckStruct
Map a Rust struct to a DuckDB
STRUCT value.Helper macros
transaction!, params!, and the UDF body macros.The #[duck(...)] attributes
FromRow, ToRow, and DuckStruct share the #[duck(...)] attribute:
- Container:
#[duck(rename_all = "…")],#[duck(crate = ::path)]. - Field:
#[duck(rename = "column")].
DuckEnum uses a separate #[duck_enum(...)] attribute with the same rename / rename_all /
crate options (so an enum can derive both DuckEnum and other #[duck]-based traits without
clashing).
The crate = ::path option retargets the generated ::better_duck_core path — useful for crates
that re-export the library under another name.
rename_all casings
rename_all accepts these casing names. Names are split into words on _ / - and at
lower→Upper boundaries, so both snake-case fields and Pascal/camel variants map correctly (a run of
uppercase letters counts as one word, e.g. HTTPServer → httpserver under snake_case):
Resolution order for a field/variant name: explicit
rename → container rename_all → the Rust
identifier verbatim.
See also
- FromRow / ToRow · DuckEnum · DuckStruct.
- Values overview — the traits these derives implement.
- Diesel docs — the extra Diesel emission these derives can produce.