Skip to main content

REnv

Struct REnv 

Source
pub struct REnv {
    sexp: SEXP,
}
Expand description

Handle to a well-known R environment.

Provides access to R’s standard environments without raw FFI calls.

Fields§

§sexp: SEXP

Implementations§

Source§

impl REnv

Source

pub unsafe fn global() -> Self

The global environment (R_GlobalEnv).

§Safety

Must be called from the R main thread.

Source

pub unsafe fn base() -> Self

The base environment (R_BaseEnv).

§Safety

Must be called from the R main thread.

Source

pub unsafe fn empty() -> Self

The empty environment (R_EmptyEnv).

§Safety

Must be called from the R main thread.

Source

pub fn base_namespace() -> Self

The base namespace (SEXP::base_namespace()).

Unlike base() which is the base environment (exported functions visible to users), this is the base namespace (includes internal helpers). Rarely needed — prefer base() unless you specifically need unexported base internals.

§Safety

Must be called from the R main thread.

Source

pub unsafe fn package_namespace(name: &str) -> Result<Self, String>

A package’s namespace environment.

Finds the namespace for a loaded package. Use this to evaluate functions that live in a specific package (e.g., slot() from methods).

This is a safe wrapper around R_FindNamespace — it uses R_tryEvalSilent internally so that a missing namespace returns Err instead of longjmping through Rust frames.

§Safety

Must be called from the R main thread.

§Errors

Returns Err if the package namespace is not found (package not loaded).

Source

pub unsafe fn caller() -> Self

The current execution environment.

Returns the environment of the innermost active closure on R’s call stack, or the global environment if no closure is active.

Useful when you need to evaluate an expression in the caller’s context rather than a fixed well-known environment.

§Safety

Must be called from the R main thread.

Source

pub unsafe fn from_sexp(sexp: SEXP) -> Self

Wrap an arbitrary environment SEXP.

§Safety

sexp must be a valid ENVSXP.

Source

pub fn as_sexp(&self) -> SEXP

Get the underlying SEXP.

Auto Trait Implementations§

§

impl Freeze for REnv

§

impl RefUnwindSafe for REnv

§

impl Send for REnv

§

impl Sync for REnv

§

impl Unpin for REnv

§

impl UnsafeUnpin for REnv

§

impl UnwindSafe for REnv

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

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

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.