ParseConfig

Struct ParseConfig 

Source
pub struct ParseConfig {
    pub max_vector_length: usize,
    pub max_allocation_bytes: usize,
    pub mode: ParseMode,
    pub lazy_threshold: usize,
    pub bytecode_lazy_threshold: usize,
}
Expand description

Configuration for parsing RDS files.

Allows customization of memory allocation limits to handle large files or enforce stricter safety constraints.

§Safety Guardrails

Note: mode does NOT override safety guardrails (max_vector_length, max_allocation_bytes). These limits are enforced even in LazyMetadata mode to protect against corrupt headers.

Fields§

§max_vector_length: usize

Maximum number of elements allowed in a vector (default: 50,000,000)

§max_allocation_bytes: usize

Maximum bytes that can be allocated for a single vector (default: 128 MB)

§mode: ParseMode

Parsing mode (default: Full)

§lazy_threshold: usize

In lazy mode, vectors smaller than this are always loaded (default: 10 elements)

Small vectors are typically metadata (dimensions, names, etc.) and should be loaded even in lazy mode for efficient structure inspection.

§bytecode_lazy_threshold: usize

In lazy mode, bytecode constants smaller than this are always loaded (default: 1000 elements)

Bytecode parsing requires extracting tag/symbol names from character vectors. This threshold is higher than lazy_threshold because:

  • Tags/symbols are almost always small (class names, function names, etc.)
  • Loading a 1000-element character vector is cheap (typically <50 KB)
  • If a tag exceeds this threshold, it will be skipped gracefully (placeholder used)
  • This prevents failures when parsing S4 objects with embedded command history

Implementations§

Source§

impl ParseConfig

Source

pub fn new() -> Self

Create a new ParseConfig with default values.

Source

pub fn with_max_vector_length(self, max: usize) -> Self

Set the maximum vector length.

Source

pub fn with_max_allocation_bytes(self, max: usize) -> Self

Set the maximum allocation bytes.

Source

pub fn with_mode(self, mode: ParseMode) -> Self

Set the parsing mode.

Source

pub fn with_lazy_threshold(self, threshold: usize) -> Self

Set the lazy threshold (vectors smaller than this are always loaded in lazy mode).

Source

pub fn with_bytecode_lazy_threshold(self, threshold: usize) -> Self

Set the bytecode lazy threshold (bytecode constants smaller than this are always loaded).

Source

pub fn lazy_metadata() -> Self

Create a config for lazy metadata parsing.

This mode parses only structure and metadata without allocating vector/matrix data, enabling:

  • Fast file inspection
  • Handling files larger than available RAM
  • Metadata extraction with minimal memory overhead
§Note

Safety guardrails (max_vector_length, max_allocation_bytes) are still enforced to protect against corrupt headers.

Source

pub fn large_data() -> Self

Create a config suitable for large scientific datasets (e.g., genomics).

Sets higher limits:

  • max_vector_length: 500,000,000 (500M elements)
  • max_allocation_bytes: 2 GB
Source

pub fn unlimited() -> Self

Create a config with unlimited size (use with caution).

Only use this when you trust the input files and have sufficient memory.

Trait Implementations§

Source§

impl Clone for ParseConfig

Source§

fn clone(&self) -> ParseConfig

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ParseConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ParseConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.