Skip to main content

field_reader_capable

Function field_reader_capable 

Source
fn field_reader_capable(rf: &ResolvedField) -> bool
Expand description

True if a resolved struct field can be read back out of an R data.frame.

Determines whether the struct gets a generated try_from_dataframe reader. Each shape’s reader is the inverse of its column-expansion write rule:

  • Single scalar: one column read as Vec<ty> (excludes as_list and opaque set/collection columns — those classify as Single but lack Vec<_>: TryFromSexp).
  • Single map column (HashMap<String, V> / BTreeMap<String, V>): one VECSXP list-of-named-lists column read whole via Vec<map>: TryFromSexp — the exact inverse of the Vec<map>: IntoR write shape (#764). Gated to String keys + reader-scalar values at resolve time (map_reader).
  • Single owned list-column: Vec<scalar> / Box<[scalar]> stored as a VECSXP list-column; the reader deserialises each row’s element via Vec<elem>: TryFromSexp and .into()-converts to the field type (#809).
  • ExpandedFixed ([T; N]): N columns regrouped into the array.
  • ExpandedVec / AutoExpandVec (Vec<T>): suffixed Option columns flattened back per row (bare-scalar elements only).
  • Struct (nested DataFrameRow): always eligible — the reader routes the un-prefixed sub-frame through the inner type’s DataFrameRowConvert, which degrades to a clear runtime error if the inner shape itself has no reader.

Borrowed expansion origins (&[T] / &[T; N]) are not readable (owned R data can’t produce a borrow) — flagged via readable at resolve time.