Expand description
Derive macros for bidirectional row β dataframe conversions.
Supports both structs (direct field mapping) and enums (field-name union
across variants with Option<T> fill for missing fields).
Re-exportsΒ§
use proc_macro2::Span;πuse proc_macro2::TokenStream;πuse quote::format_ident;πuse quote::quote;πuse quote::quote_spanned;πuse syn::Data;πuse syn::DeriveInput;πuse syn::Fields;πuse enum_expansion::derive_enum_dataframe;π
ModulesΒ§
- enum_
expansion π - Enum-specific DataFrame derive expansion.
StructsΒ§
- Auto
Expand πVecData - Data for
ResolvedField::AutoExpandVec. - Column
Registry π - Accumulates unique columns for an enum-to-dataframe unified schema.
- Data
Frame πAttrs - Parsed container-level
#[dataframe(...)]attributes. - Enum
Auto πExpand VecData - Data for
EnumResolvedField::AutoExpandVec. - Enum
Expanded πFixed Data - Data for
EnumResolvedField::ExpandedFixed. - Enum
Expanded πVecData - Data for
EnumResolvedField::ExpandedVec. - Enum
MapField πData - Data for
EnumResolvedField::Map. - Enum
Single πField Data - Data for
EnumResolvedField::Single. - Enum
Struct πField Data - Data for
EnumResolvedField::Struct. - Expanded
Fixed πData - Data for
ResolvedField::ExpandedFixed. - Expanded
VecData π - Data for
ResolvedField::ExpandedVec. - Field
Attrs π - Parsed field-level
#[dataframe(...)]attributes. - MapField
Data π - Data for
ResolvedField::Map(struct path, non-String-keyed maps, #919). - Resolved
Column π - A resolved column in the unified schema across all enum variants.
- Single
Field πData - Data for
ResolvedField::Single. - Struct
Field πData - Data for
ResolvedField::Struct. - Variant
Info π - Parsed and resolved information about a single enum variant for DataFrame codegen.
EnumsΒ§
- Enum
Resolved πField - A resolved enum field ready for codegen β either a single column or expanded from an array/Vec into multiple suffixed columns.
- Field
Type πKind - Classification of a field type for DataFrame column expansion.
- Resolved
Field π - A resolved struct field ready for codegen β determines how this field maps to DataFrame companion struct columns.
- Variant
Shape π - Describes the shape of an enum variantβs fields.
ConstantsΒ§
- DATETIME_
PATHS π - Datetime types that
DataFrameRowstores as one column (T) or one NA-able column (Option<T>): miniextendr-api hasIntoRandTryFromSexpforVec<T>andVec<Option<T>>of each, under itsjiff/timefeature. - OPTION_
SCALAR_ πNAMES - Scalar types accepted inside
Option<β¦>as a struct-path field (#1437): everyThere hasIntoR for Vec<Option<T>>(typedNAforNone) inminiextendr-api::into_r. The reader side is gated separately byis_reader_scalar_ty, soOption<u64>/Option<usize>fields are write-only, like their bare counterparts. - READER_
SCALAR_ πNAMES - Scalar element types whose
Vec<T>(andVec<Option<T>>) round-trips throughTryFromSexpβ the supported field types for the parallel from-R reader (try_from_dataframe_par). This is intentionally narrower thanFieldTypeKind::Scalar: set/opaque collection types (HashSet<β¦>,BTreeSet<β¦>) also classify asScalarbut do NOT implementVec<_>: TryFromSexp, so they must be excluded from the reader path. - SPELL_
TYPES_ πALIKE - The fix every cross-variant type-conflict error offers first: the derive
compares spellings (
same_column_type), so one type needs one spelling.
FunctionsΒ§
- borrowed_
string_ πcolumn - The element type of a borrowed fillβs string column, with the
Stringtype it borrows from:&strfor aStringcolumn,Option<&str>for anOption<String>one,Nonefor every other column. These columns are written from the rowβs own string (StringColumn, which onlystd::string::Stringimplements), andVec<&str>/Vec<Option<&str>>convert to the same character vector as the owned column. - classify_
field_ πtype - Classify a field type for DataFrame column expansion.
- column_
local π - The local a fill (the owned
From<Vec<Row>>, or the borrowedDataFrameRowBorrow) keeps columnnamein. Prefixed, so no column can shadow the fillβs own bindings (rows,row,len,__mx_row,__mx_len): a field namedlenused to break the owned fill. - column_
sexp π - Convert a column (
access: the companionβs field, or the borrowed fillβs local) without adding R objects to the companion:as_listuses the rooted list builder,as_factorusesUnitEnumFactor, and ordinary columns convert the wholeVecthroughIntoR. - column_
str π - The
&strof aStringvalue (value: an expression of type&String). - column_
str_ πfn StringColumn::__mx_column_stras a function, forOption::map.- companion_
debug_ πclone DebugandClonefor a companion, each implemented only when every field type has it.#[derive(Debug, Clone)]would demand both of every columnβs element type (#2013).fieldsare the companionβs fields with their types.- companion_
lifetime_ πmarker - Keep lifetimes erased by column expansion or skipped fields in the companion. Columns that still borrow already carry their lifetimes; only missing ones need a marker. This adds no data column or element-type trait requirements.
- conditional_
where π whereclause:where_clauseβs predicates, thenfor<'__mx_cond> ty: boundfor each(ty, bound)pair.- datetime_
column_ πty - The datetime type of a
TorOption<T>field (DATETIME_PATHS). - datetime_
feature_ πassertions - One compile-time check per datetime type in
tys: without the matching miniextendr-api feature, the field reports the feature to enable (markers::DataFrameDateTime) instead of a bare missingIntoRimpl. - datetime_
path π - The
DATETIME_PATHSentrytpspells, with or without a leading::or theminiextendr_api::re-export of the crate. - derive_
dataframe_ row - Derive
DataFrameRow: generates a companion DataFrame type with collection fields. - derive_
struct_ πdataframe - Generate
DataFrameRowexpansion for struct types. - expanded_
elem_ πidents - The variables
fixed_array_elems/width_elemsbind for thencolumns of the fieldkeynames. Leading underscores are dropped fromkeyso the variables stay snake case (_0gives__mxe1_0). - field_
is_ πborrowed_ ref - True if
tyis a borrowed reference (&[T],&[T; N],&str, β¦). Such expansion fields canβt be reconstructed by value in the RβRust reader. - field_
reader_ πcapable - True if a resolved struct field can be read back out of an R
data.frame. - fixed_
array_ πelems - Bind each element of fixed-array field value
accessto its own variable inelems: moved out of an owned array (indexing would needCopy), cloned out of a borrowed one, which is the only way to own an element behind a reference. - from_
rows_ πpar_ override - The
from_rows_paroverride of a companionβsColumnarFrameimpl: the companionβsParallelColumnsimpl where it applies,from_rowsotherwise (miniextendr_api::dataframe::FromRowsParProbe). - generic_
type_ πarg_ count - Number of type arguments on
tyβs last path segment (0 when not angle-bracketed). RejectsHashMap<K, V, S>custom-hasher maps from the reader path β theVec<HashMap<String, V>>: TryFromSexpimpl only covers the default hasher. - is_
bare_ πreader_ scalar_ ty - True if
tynames a known scalar, qualified or bare (noOptionor generics). - is_
datetime_ πty - True if
tyis a datetime type spelled by its crate path (DATETIME_PATHS). - is_
known_ πscalar_ ty - Match the final scalar name, as field classification does. Absolute and relative paths have the same conversion support; associated types and generic payloads still need their own classification.
- is_
option_ πscalar_ inner - True if
tynames a type fromOPTION_SCALAR_NAMES(possibly qualified, without generic args), a valid payload for a single NA-able column. - is_
raw_ πscalar_ ty - True if
tyisu8, bare or qualified. R stores it in a raw vector, which has no NA, so au8column cannot pad or omit cells (Vec<Option<u8>>has noIntoR). - is_
reader_ πscalar_ ty - True if
tyis a known scalar path, orOption<known-scalar>. - is_
string_ πty - True if
tyβs last path segment is the bare identString(path-identity check, same convention asclassify_field_type). - list_
column_ πfn into_list_column::<#ty>(orinto_option_list_column::<#ty>, for a column with absent rows), spanned at the field type: a type withoutIntoListis then reported at the field instead of at the derive.- option_
payload π - The payload of
Option<T>(possibly qualified), iftyis one. - owned_
elems_ πiter - The elements of an expanded
Vec<T>/Box<[T]>/&[T]field valueaccessas an iterator of ownedT: moved out of an owned container, cloned out of a borrowed slice.IntoIterator::into_iteris called by path so aBox<[T]>iterates by value in every edition. - parallel_
columns_ πimpl - The parallel column fill of a companion:
ParallelColumnswithbodyasfrom_rows_parallel(rows), implemented only whereboundshold (seeminiextendr_api::dataframe::ParallelColumns). Emitted only when miniextendr-api hasrayon; pair it withfrom_rows_par_override. - parse_
dataframe_ πattrs - Parse container-level
#[dataframe(...)]attributes from the derive input. - parse_
field_ πattrs - Parse field-level
#[dataframe(...)]attributes from asyn::Field. - raw_
na_ πcolumn_ error - A
u8in a column whose cells can be NA.whynames the source of the NA cells andfixthe alternative, so the error points at the field instead of the missingIntoRimpl inside the generated code (#2025). - resolve_
struct_ πfield - Resolve a struct field into a
ResolvedField, applying field attributes. - same_
column_ πtype - Compare column types using canonical standard-library spellings, without changing the type emitted for the first variant. Recurse through containers and references, but never discard arbitrary user module paths or qself.
- spanned_
clone_ πfn <ty as Clone>::clone, spanned atty: a type withoutCloneis then reported at the userβs field instead of at the derive.- validate_
factor_ πfield_ type - The same
as_factorshapes are accepted on struct and enum fields. The generated conversion checksUnitEnumFactoron the selected type. - width_
elems π - Bind the first
elems.len()elements of awidth = Nfield valueaccesstoOption<T>variables (Nonepast its end; elements pastNare dropped), through iterator variableiter.