Skip to main content

Module list_derive

Module list_derive 

Source
Expand description

§List and Preference Derive Macros

This module implements derive macros for bidirectional Rust struct <-> R list conversion, plus “preference” derives that control how a type is converted to R when returned from #[miniextendr] functions.

§List Derives

  • #[derive(IntoList)] – Rust struct -> R named/unnamed list
  • #[derive(TryFromList)] – R list -> Rust struct

§Preference Derives

These marker derives select the IntoR strategy for a type. Only one preference derive should be applied to a given type:

  • #[derive(PreferList)] – convert via IntoList::into_list
  • #[derive(PreferExternalPtr)] – wrap in ExternalPtr::new
  • #[derive(PreferDataFrame)] – convert via IntoDataFrame::into_data_frame
  • #[derive(PreferRNativeType)] – convert via AsRNative wrapper

§Field Attributes

  • #[into_list(ignore)] – skip this field during IntoList/TryFromList conversion. For TryFromList, ignored fields are filled with Default::default().

Functions§

derive_into_list
Derive IntoList for structs (Rust -> R).
derive_prefer_data_frame
Derive PreferDataFrame: adds the PrefersDataFrame marker trait and an IntoR impl that converts to R via IntoDataFrame::into_data_frame, then into_sexp.
derive_prefer_externalptr
Derive PreferExternalPtr: adds the PrefersExternalPtr marker trait and an IntoR impl that wraps the value in ExternalPtr::new before converting to SEXP.
derive_prefer_list
Derive PreferList: adds the PrefersList marker trait and an IntoR impl that converts to R by first calling IntoList::into_list, then into_sexp.
derive_prefer_rnative
Derive PreferRNativeType: adds the PrefersRNativeType marker trait and an IntoR impl that wraps the value in AsRNative(self) before calling IntoR::into_sexp.
derive_try_from_list
Derive TryFromList for structs (R -> Rust).
field_is_ignored 🔒
Check whether a struct field has the #[into_list(ignore)] attribute.