Skip to main content

DataFrameShape

Enum DataFrameShape 

Source
pub enum DataFrameShape {
    Bare(BuiltDataFrame),
    Split {
        results: SplitResults,
        error: BuiltDataFrame,
    },
    PerVariantList(Vec<(String, BuiltDataFrame)>),
}
Expand description

Categorical return shape of the data.frame split verbs: IntoDataFrameSplit::into_dataframe_split and the serde helpers vec_to_dataframe_split / result_to_dataframe (feature = "serde").

Carries enough type information that downstream Rust code can match on the variant without dispatching on SEXP type. Convert to a SEXP via the IntoR impl (or just return it from a #[miniextendr] fn), which collapses every variant to the equivalent R value (bare data.frame / named list of data.frames / list(results=, error=)).

§GC discipline (rooted by construction, #1265, #1750)

Every frame inside the shape is an owned, GC-rooted BuiltDataFrame, and the SplitResults::None sentinel carries its own Preserved root — so holding a DataFrameShape across R allocations is safe by construction; there is no convert-immediately contract. The IntoR conversion consumes the handles, re-rooting each child in the assembled R value.

Variants§

§

Bare(BuiltDataFrame)

Single data.frame.

Used by:

  • into_dataframe_split on a single-variant enum, always.
  • serde vec_to_dataframe_split when only one variant is present (and SplitShape::PerVariantList or SplitShape::PerVariantListWithTag is selected — the single-variant short-circuit) or always under SplitShape::Collated.
  • serde result_to_dataframe under ResultShape::Auto when every row is Ok, and always under ResultShape::Collated.
§

Split

list(results = <df | sentinel>, error = df).

Produced only by serde result_to_dataframe: under ResultShape::Auto when at least one Err is present, and always under ResultShape::Split. The split verbs never produce it.

Fields

§results: SplitResults

The Ok partition.

§error: BuiltDataFrame

The error partition (always present, possibly zero-row).

§

PerVariantList(Vec<(String, BuiltDataFrame)>)

list(VariantA = df, VariantB = df, …).

Produced by:

  • into_dataframe_split on a multi-variant enum, always: one entry per declared variant, in declaration order, keyed by the snake_case variant name. A variant absent from the input is a 0-row frame with that variant’s columns.
  • serde vec_to_dataframe_split under SplitShape::PerVariantList / SplitShape::PerVariantListWithTag when the input contains more than one variant. Order matches first-seen order in the input slice.

Trait Implementations§

Source§

impl IntoR for DataFrameShape

Source§

type Error = !

The error type for fallible conversions. Read more
Source§

fn try_into_sexp(self) -> Result<SEXP, Self::Error>

Try to convert this value to an R SEXP. Read more
Source§

unsafe fn try_into_sexp_unchecked(self) -> Result<SEXP, Self::Error>

Try to convert to SEXP without thread safety checks. Read more
Source§

fn into_sexp(self) -> SEXP
where Self: Sized,

Convert this value to an R SEXP, panicking on error. Read more
Source§

unsafe fn into_sexp_unchecked(self) -> SEXP
where Self: Sized,

Convert to SEXP without thread safety checks, panicking on error. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> SizeHint for T
where T: ?Sized,

Source§

default fn lower_bound(&self) -> usize

🔬This is a nightly-only experimental API. (core_io_internals)
Returns a lower bound on the number of elements this container-like item contains. For example, an array [u8; 12] could return any value between 0 and 12 inclusively as a correct implementation. Read more
Source§

default fn upper_bound(&self) -> Option<usize>

🔬This is a nightly-only experimental API. (core_io_internals)
Returns an upper bound on the number of elements this container-like item contains if it can be determined, otherwise None. Read more
Source§

final fn size_hint(&self) -> (usize, Option<usize>)

🔬This is a nightly-only experimental API. (core_io_internals)
Returns an estimate for the number of elements this container like type contains. Read more
Source§

impl<T> SizedTypeProperties for T

Source§

#[doc(hidden)]
const SIZE: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const ALIGN: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const ALIGNMENT: Alignment = _

🔬This is a nightly-only experimental API. (ptr_alignment_type)
Source§

#[doc(hidden)]
const IS_ZST: bool = _

🔬This is a nightly-only experimental API. (sized_type_properties)
true if this type requires no storage. false if its size is greater than zero. Read more
Source§

#[doc(hidden)]
const LAYOUT: Layout = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const MAX_SLICE_LEN: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
The largest safe length for a [Self]. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 40 bytes

Size for each variant:

  • Bare: 24 bytes
  • Split: 40 bytes
  • PerVariantList: 32 bytes