Requires
feature = "derive". See the derives overview for the shared #[duck(...)] attributes and rename_all casings.#[derive(DuckStruct)] maps a Rust named-field struct to a DuckDB STRUCT value (named fields,
fixed schema). It generates From<T> for DuckValue and FromDuckValue for T, so the struct
converts to and from a DuckValue::Struct.
#[duck(rename = "…")] / #[duck(rename_all = "…")] / #[duck(crate = …)]
attributes as #[derive(FromRow)], with the same
resolution order.
DuckStruct maps to a DuckDB STRUCT value (a column value), whereas
FromRow maps a whole query row. Reach for DuckStruct when a
single column is itself a STRUCT; reach for FromRow to read a result set’s rows.Diesel emission
With better-duck-diesel’sderive feature on, #[derive(DuckStruct)] additionally emits Diesel
ToSql / FromSql against better_duck_diesel::sql_types::DuckStruct (via sql_query +
QueryableByName, routing through the DuckDb backend), so the same type binds and loads through a
DuckDbConnection. The deriving crate must then depend on better-duck-diesel — see the
Diesel docs. Nothing extra is emitted with the feature off.
See also
- DuckEnum derive · FromRow / ToRow.
- Composite types — the runtime
DuckStructvalue. - Derives overview — the
rename_allcasings table.