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: SEXPImplementations§
Source§impl REnv
impl REnv
Sourcepub fn base_namespace() -> Self
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.
Sourcepub unsafe fn package_namespace(name: &str) -> Result<Self, String>
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).
Sourcepub unsafe fn caller() -> Self
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.