pub(super) fn derive_enum_dataframe(
row_name: &Ident,
input: &DeriveInput,
data: &DataEnum,
df_name: &Ident,
attrs: &DataFrameAttrs,
) -> Result<TokenStream>Expand description
Derive DataFrameRow for an enum with #[dataframe(align)].
Generates a companion struct where every column is Vec<Option<T>>, with
None fill for fields absent in a given variant. This is the enum counterpart
of super::derive_struct_dataframe.
§Generated items
- Companion struct
{Name}DataFramewithVec<Option<T>>columns (field-name union) - Optional
_tag: Vec<String>column for variant discrimination impl IntoDataFrame(companion → R data.frame) andimpl ColumnarFrame(rows ↔ the pure-Rust companion:from_rows/from_rows_par)impl From<Vec<Enum>>(sequential row->column transposition)impl DataFrameRowSpliton the enum — the split (one-data.frame-per-variant) representation, surfaced asrows.into_dataframe_split()viaIntoDataFrameSplit’s blanket impl
The write/read verbs are the trait surface — rows.into_dataframe()?
(IntoDataFrame / AsDataFrameExt), rows.into_dataframe_split()
(IntoDataFrameSplit), Vec::<Row>::from_dataframe(&df)?
(FromDataFrame) or the one-call Row::try_from_dataframe(sexp) reader, and the
pure-Rust ColumnarFrame companion verbs. The row type keeps two #[doc(hidden)]
helpers: to_dataframe(rows) -> companion for the nested-companion write path
(Inner::to_dataframe(..) without naming the inner companion type) and
to_dataframe_split(rows), the body holder behind the DataFrameRowSplit bridge.
§Variant support
- Named variants (
{ field: T }): fields contribute by name to the unified schema - Tuple variants (
(T, U)): fields are named_0,_1, etc. - Unit variants: contribute no columns (only tag if present)
§Auto-expand fields
Fields with #[dataframe(expand)] on Vec<T> types get dynamic column counts
determined at runtime from the maximum row length across all rows. These are
tracked separately from the static ColumnRegistry.
Returns Err if the enum has no variants or if type conflicts arise without
#[dataframe(conflicts = "string")].