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: usizeMaximum number of elements allowed in a vector (default: 50,000,000)
max_allocation_bytes: usizeMaximum bytes that can be allocated for a single vector (default: 128 MB)
mode: ParseModeParsing mode (default: Full)
lazy_threshold: usizeIn 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: usizeIn 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
impl ParseConfig
Sourcepub fn with_max_vector_length(self, max: usize) -> Self
pub fn with_max_vector_length(self, max: usize) -> Self
Set the maximum vector length.
Sourcepub fn with_max_allocation_bytes(self, max: usize) -> Self
pub fn with_max_allocation_bytes(self, max: usize) -> Self
Set the maximum allocation bytes.
Sourcepub fn with_lazy_threshold(self, threshold: usize) -> Self
pub fn with_lazy_threshold(self, threshold: usize) -> Self
Set the lazy threshold (vectors smaller than this are always loaded in lazy mode).
Sourcepub fn with_bytecode_lazy_threshold(self, threshold: usize) -> Self
pub fn with_bytecode_lazy_threshold(self, threshold: usize) -> Self
Set the bytecode lazy threshold (bytecode constants smaller than this are always loaded).
Sourcepub fn lazy_metadata() -> Self
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.
Sourcepub fn large_data() -> Self
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
Trait Implementations§
Source§impl Clone for ParseConfig
impl Clone for ParseConfig
Source§fn clone(&self) -> ParseConfig
fn clone(&self) -> ParseConfig
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ParseConfig
impl Debug for ParseConfig
Auto Trait Implementations§
impl Freeze for ParseConfig
impl RefUnwindSafe for ParseConfig
impl Send for ParseConfig
impl Sync for ParseConfig
impl Unpin for ParseConfig
impl UnwindSafe for ParseConfig
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)