RObject

Enum RObject 

Source
#[non_exhaustive]
pub enum RObject {
Show 30 variants Null, Integer(VectorData<i32>), Real(VectorData<f64>), Logical(VectorData<Logical>), Character(VectorData<Arc<str>>), Symbol(Arc<str>), Raw(VectorData<u8>), Complex(VectorData<Complex>), List(Vec<RObject>), Pairlist(Vec<PairlistElement>), Language { function: Box<RObject>, args: Vec<PairlistElement>, }, Expression(Vec<RObject>), Closure { formals: Box<RObject>, body: Box<RObject>, environment: Box<RObject>, }, Environment { enclosing: Box<RObject>, frame: Box<RObject>, hashtab: Box<RObject>, }, Promise { value: Box<RObject>, expression: Box<RObject>, environment: Box<RObject>, }, Special { name: Arc<str>, }, Builtin { name: Arc<str>, }, Bytecode { code: Box<RObject>, constants: Box<RObject>, expr: Box<RObject>, }, DataFrame(Box<DataFrameData>), Factor(Box<FactorData>), S3Object(Box<S3ObjectData>), S4Object(Box<S4ObjectData>), Namespace(Vec<Arc<str>>), GlobalEnv, BaseEnv, EmptyEnv, MissingArg, UnboundValue, Shared(Arc<RwLock<RObject>>), WithAttributes { object: Box<RObject>, attributes: Attributes, },
}
Expand description

Represents any R object that can be stored in an RDS file.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Null

NULL object

§

Integer(VectorData<i32>)

Integer vector (can be fully loaded or lazy)

§

Real(VectorData<f64>)

Real (double) vector (can be fully loaded or lazy)

§

Logical(VectorData<Logical>)

Logical vector (can be fully loaded or lazy)

§

Character(VectorData<Arc<str>>)

Character vector (using Arc for string interning, can be fully loaded or lazy)

§

Symbol(Arc<str>)

Symbol (SYMSXP) - a named symbol Used for R’s internal symbol table and special markers

§

Raw(VectorData<u8>)

Raw (byte) vector (can be fully loaded or lazy)

§

Complex(VectorData<Complex>)

Complex vector (can be fully loaded or lazy)

§

List(Vec<RObject>)

Generic list (VECSXP)

§

Pairlist(Vec<PairlistElement>)

Pairlist (LISTSXP) with optional tags

§

Language

Language object (unevaluated call/expression) Contains the function being called and its arguments with optional names

Fields

§function: Box<RObject>
§

Expression(Vec<RObject>)

Expression vector (vector of language objects) Typically the result of parse() - a collection of unevaluated expressions

§

Closure

Closure (function) Contains formal parameters, body, and enclosing environment

Fields

§formals: Box<RObject>
§body: Box<RObject>
§environment: Box<RObject>
§

Environment

Environment Contains parent environment, bindings frame, and hash table

Fields

§enclosing: Box<RObject>
§frame: Box<RObject>
§hashtab: Box<RObject>
§

Promise

Promise (lazy evaluation) Contains value, expression, and environment

Fields

§value: Box<RObject>
§expression: Box<RObject>
§environment: Box<RObject>
§

Special

Special primitive function (like ‘if’, ‘for’, ‘while’) These are internal R functions with special evaluation rules

Fields

§name: Arc<str>
§

Builtin

Builtin primitive function (like ‘sum’, ‘c’, ‘+’) These are internal R functions evaluated normally

Fields

§name: Arc<str>
§

Bytecode

Bytecode (compiled R function) Contains code vector, constants pool, and original expression

Fields

§code: Box<RObject>
§constants: Box<RObject>
§expr: Box<RObject>
§

DataFrame(Box<DataFrameData>)

Data frame (list with class=“data.frame”) Boxed to reduce enum size

§

Factor(Box<FactorData>)

Factor (categorical variable with levels) Boxed to reduce enum size

§

S3Object(Box<S3ObjectData>)

S3 object (any object with a class attribute) Boxed to reduce enum size

§

S4Object(Box<S4ObjectData>)

S4 object (formal object with slots) Boxed to reduce enum size

§

Namespace(Vec<Arc<str>>)

Namespace reference (triggers automatic package loading in R) Contains namespace name components (e.g., [“Matrix”] or [“base”])

§

GlobalEnv

Global environment reference This is a singleton in R that persists across the session

§

BaseEnv

Base environment reference Contains base package bindings

§

EmptyEnv

Empty environment reference The root of the environment tree (has no parent)

§

MissingArg

Missing argument marker Used for default arguments in function formals

§

UnboundValue

Unbound value marker Used to indicate an unbound variable

§

Shared(Arc<RwLock<RObject>>)

Shared reference to an existing object (used for REFSXP backreferences) to avoid deep cloning large structures during parsing.

§

WithAttributes

Object with attributes (no class)

Fields

§object: Box<RObject>
§attributes: Attributes

Implementations§

Source§

impl RObject

Source

pub fn as_concrete(&self) -> RObject

If this object is a Shared wrapper, return the underlying object reference. Otherwise return self.

Source

pub fn into_concrete(self) -> RObject

Consume the object, unwrapping Shared by cloning the underlying object.

Source

pub fn into_concrete_deep(self) -> RObject

Recursively convert all Shared wrappers to concrete objects throughout the entire tree.

This is essential for thread safety when the resulting RObject will be used across threads. While each parse has its own RefTable, nested Shared objects (in Lists, Pairlists, WithAttributes, etc.) share Arc pointers that can cause race conditions when accessed concurrently from different threads.

Uses cycle detection to handle circular references (e.g., in environments).

Source

pub fn variant_name(&self) -> &'static str

Human-friendly variant name for debugging.

Source

pub fn is_fully_loaded(&self) -> bool

Check if this object is fully loaded (no lazy vectors).

Returns true if all vector data is materialized (Owned), false if any vector is in Lazy state. For non-vector objects, recursively checks nested objects.

Note: Uses cycle detection to handle circular references in environments/promises.

Source

pub fn lazy_spans(&self) -> Vec<(String, LazyVector)>

Collect all lazy vector spans in this object tree.

Returns a vector of tuples containing the path to each lazy vector and its LazyVector metadata (offset, byte_len, length). The path is a dot-separated string describing the location (e.g., “columns.gene_names” for a DataFrame column).

This is useful for understanding the lazy structure of a parsed RDS file.

Note: Uses cycle detection to handle circular references in environments/promises.

Source§

impl RObject

Source

pub const NA_INTEGER: i32 = -2_147_483_648i32

Integer NA value in R

Source

pub fn is_na_integer(val: i32) -> bool

Check if an integer is NA

Trait Implementations§

Source§

impl Clone for RObject

Source§

fn clone(&self) -> RObject

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 RObject

Source§

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

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

impl PartialEq for RObject

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

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.