pub struct NamedDataFrameListBuilder {
scope: ProtectScope,
pairs: Vec<(String, SEXP)>,
}Expand description
Assemble a named list whose elements are DataFrames,
without per-result OwnedProtect bookkeeping.
§Why this is distinct from DataFrame::builder
DataFrame::builder and the serde
SerdeRowBuilder both produce a single DataFrame. This builder
produces a different shape — a named list of data.frames, e.g.
list(results = df, error = df) — so it deliberately keeps its own name
rather than folding into the DataFrame::builder vocabulary. Its inputs
are DataFrames (from any producer: IntoDataFrame, the serde
vec_to_dataframe, or GroupedDataFrame::frames); its output is a
List.
Each push protects the input
data.frame’s SEXP via an internal ProtectScope;
build consumes the builder and emits
a named list via List::from_raw_pairs.
The scope drops at the end of build, releasing the per-input protects —
by which point the children are reachable from the assembled list.
§Example
let result = NamedDataFrameListBuilder::new()
.push("results", oks.into_dataframe()?)
.push("error", errs.into_dataframe()?)
.build();Fields§
§scope: ProtectScope§pairs: Vec<(String, SEXP)>Implementations§
Source§impl NamedDataFrameListBuilder
impl NamedDataFrameListBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty builder.
§Safety (caller)
Must be called from the R main thread. The internal
ProtectScope carries !Send + !Sync
so the builder cannot be moved to another thread.
Sourcepub fn with_capacity(n: usize) -> Self
pub fn with_capacity(n: usize) -> Self
Create a builder pre-allocated for n entries.
Equivalent to new but avoids repeated re-allocations
when the number of partitions is known up front.
Sourcepub fn push<S: Into<String>>(self, name: S, df: DataFrame) -> Self
pub fn push<S: Into<String>>(self, name: S, df: DataFrame) -> Self
Append a named data.frame. The input’s SEXP is protected internally for the lifetime of the builder.
Sourcepub fn build(self) -> List
pub fn build(self) -> List
Consume the builder and return the assembled named List.
The returned List’s SEXP is not separately protected on return — the
caller takes responsibility for protection (typically by immediately
handing it back to R via the .Call return path). This matches the
contract of List::from_raw_pairs.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for NamedDataFrameListBuilder
impl !RefUnwindSafe for NamedDataFrameListBuilder
impl !Send for NamedDataFrameListBuilder
impl !Sync for NamedDataFrameListBuilder
impl Unpin for NamedDataFrameListBuilder
impl UnsafeUnpin for NamedDataFrameListBuilder
impl UnwindSafe for NamedDataFrameListBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> SizeHint for Twhere
T: ?Sized,
impl<T> SizeHint for Twhere
T: ?Sized,
Source§default fn lower_bound(&self) -> usize
default fn lower_bound(&self) -> usize
core_io_internals)[u8; 12] could return any value between 0 and
12 inclusively as a correct implementation. Read moreSource§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
ptr_alignment_type)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
sized_type_properties)[Self]. Read moreLayout§
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: 32 bytes