Skip to main content

Module dataframe_derive

Module dataframe_derive 

Source
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).

ModulesΒ§

enum_expansion πŸ”’
Enum-specific DataFrame derive expansion.

StructsΒ§

AutoExpandVecData πŸ”’
Data for ResolvedField::AutoExpandVec.
ColumnRegistry πŸ”’
Accumulates unique columns for an enum-to-dataframe unified schema.
DataFrameAttrs πŸ”’
Parsed container-level #[dataframe(...)] attributes.
EnumAutoExpandVecData πŸ”’
Data for EnumResolvedField::AutoExpandVec.
EnumExpandedFixedData πŸ”’
Data for EnumResolvedField::ExpandedFixed.
EnumExpandedVecData πŸ”’
Data for EnumResolvedField::ExpandedVec.
EnumMapFieldData πŸ”’
Data for EnumResolvedField::Map.
EnumSingleFieldData πŸ”’
Data for EnumResolvedField::Single.
EnumStructFieldData πŸ”’
Data for EnumResolvedField::Struct.
ExpandedFixedData πŸ”’
Data for ResolvedField::ExpandedFixed.
ExpandedVecData πŸ”’
Data for ResolvedField::ExpandedVec.
FieldAttrs πŸ”’
Parsed field-level #[dataframe(...)] attributes.
MapFieldData πŸ”’
Data for ResolvedField::Map (struct path, non-String-keyed maps, #919).
ResolvedColumn πŸ”’
A resolved column in the unified schema across all enum variants.
SingleFieldData πŸ”’
Data for ResolvedField::Single.
StructFieldData πŸ”’
Data for ResolvedField::Struct.
VariantInfo πŸ”’
Parsed and resolved information about a single enum variant for DataFrame codegen.

EnumsΒ§

EnumResolvedField πŸ”’
A resolved enum field ready for codegen – either a single column or expanded from an array/Vec into multiple suffixed columns.
FieldTypeKind πŸ”’
Classification of a field type for DataFrame column expansion.
ResolvedField πŸ”’
A resolved struct field ready for codegen – determines how this field maps to DataFrame companion struct columns.
VariantShape πŸ”’
Describes the shape of an enum variant’s fields.

ConstantsΒ§

OPTION_SCALAR_NAMES πŸ”’
Scalar types accepted inside Option<…> as a struct-path field (#1437): every T here has IntoR for Vec<Option<T>> (typed NA for None) in miniextendr-api::into_r. The reader side is gated separately by is_reader_scalar_ty, so Option<u64> / Option<usize> fields are write-only, like their bare counterparts.
READER_SCALAR_NAMES πŸ”’
Scalar element types whose Vec<T> (and Vec<Option<T>>) round-trips through TryFromSexp β€” the supported field types for the parallel from-R reader (try_from_dataframe_par). This is intentionally narrower than FieldTypeKind::Scalar: set/opaque collection types (HashSet<…>, BTreeSet<…>) also classify as Scalar but do NOT implement Vec<_>: TryFromSexp, so they must be excluded from the reader path.

FunctionsΒ§

classify_field_type πŸ”’
Classify a field type for DataFrame column expansion.
column_sexp πŸ”’
Convert a companion column without adding R objects to the companion: as_list uses the rooted list builder, as_factor uses UnitEnumFactor, and ordinary columns convert the whole Vec through IntoR.
companion_debug_clone πŸ”’
Debug and Clone for a companion, each implemented only when every field type has it. #[derive(Debug, Clone)] would demand both of every column’s element type (#2013). fields are 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 πŸ”’
where clause: where_clause’s predicates, then for<'__mx_cond> ty: bound for each (ty, bound) pair.
derive_dataframe_row
Derive DataFrameRow: generates a companion DataFrame type with collection fields.
derive_struct_dataframe πŸ”’
Generate DataFrameRow expansion for struct types.
expanded_elem_idents πŸ”’
The variables fixed_array_elems / width_elems bind for the n columns of the field key names. Leading underscores are dropped from key so the variables stay snake case (_0 gives __mxe1_0).
field_is_borrowed_ref πŸ”’
True if ty is 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 access to its own variable in elems: moved out of an owned array (indexing would need Copy), 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_par override of a companion’s ColumnarFrame impl: the companion’s ParallelColumns impl where it applies, from_rows otherwise (miniextendr_api::dataframe::FromRowsParProbe).
generic_type_arg_count πŸ”’
Number of type arguments on ty’s last path segment (0 when not angle-bracketed). Rejects HashMap<K, V, S> custom-hasher maps from the reader path β€” the Vec<HashMap<String, V>>: TryFromSexp impl only covers the default hasher.
is_bare_reader_scalar_ty πŸ”’
True if ty names a known scalar, qualified or bare (no Option or generics).
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 ty names a type from OPTION_SCALAR_NAMES (possibly qualified, without generic args), a valid payload for a single NA-able column.
is_raw_scalar_ty πŸ”’
True if ty is u8, bare or qualified. R stores it in a raw vector, which has no NA, so a u8 column cannot pad or omit cells (Vec<Option<u8>> has no IntoR).
is_reader_scalar_ty πŸ”’
True if ty is a known scalar path, or Option<known-scalar>.
is_string_ty πŸ”’
True if ty’s last path segment is the bare ident String (path-identity check, same convention as classify_field_type).
list_column_fn πŸ”’
into_list_column::<#ty> (or into_option_list_column::<#ty>, for a column with absent rows), spanned at the field type: a type without IntoList is then reported at the field instead of at the derive.
option_payload πŸ”’
The payload of Option<T> (possibly qualified), if ty is one.
owned_elems_iter πŸ”’
The elements of an expanded Vec<T> / Box<[T]> / &[T] field value access as an iterator of owned T: moved out of an owned container, cloned out of a borrowed slice. IntoIterator::into_iter is called by path so a Box<[T]> iterates by value in every edition.
parallel_columns_impl πŸ”’
The parallel column fill of a companion: ParallelColumns with body as from_rows_parallel(rows), implemented only where bounds hold (see miniextendr_api::dataframe::ParallelColumns). Emitted only when miniextendr-api has rayon; pair it with from_rows_par_override.
parse_dataframe_attrs πŸ”’
Parse container-level #[dataframe(...)] attributes from the derive input.
parse_field_attrs πŸ”’
Parse field-level #[dataframe(...)] attributes from a syn::Field.
raw_na_column_error πŸ”’
A u8 in a column whose cells can be NA. why names the source of the NA cells and fix the alternative, so the error points at the field instead of the missing IntoR impl inside the generated code (#2025).
resolve_struct_field πŸ”’
Resolve a struct field into a ResolvedField, applying field attributes.
spanned_clone_fn πŸ”’
<ty as Clone>::clone, spanned at ty: a type without Clone is then reported at the user’s field instead of at the derive.
validate_factor_field_type πŸ”’
The same as_factor shapes are accepted on struct and enum fields. The generated conversion checks UnitEnumFactor on the selected type.
width_elems πŸ”’
Bind the first elems.len() elements of a width = N field value access to Option<T> variables (None past its end; elements past N are dropped), through iterator variable iter.