Expand description
miniextendr-api: core runtime for Rust <-> R interop.
This crate provides the FFI surface, safety wrappers, and macro re-exports used by most miniextendr users. It is the primary dependency for building Rust-powered R packages and exposing Rust types to R.
At a glance:
- FFI bindings + checked wrappers for R’s C API (
sys,r_ffi_checked). - Conversions between Rust and R types (
IntoR,TryFromSexp,Coerce). - ALTREP traits, registration helpers, and iterator-backed ALTREP data types.
- Wrapper generation from Rust signatures (
#[miniextendr], automatic registration via linkme). - Worker-thread pattern for panic isolation and
Dropsafety (worker). - Class system support (S3, S4, S7, R6, env-style impl blocks).
- Cross-package trait ABI for type-erased dispatch (
trait_abi).
Most users should depend on this crate directly. For embedding R in
standalone binaries or integration tests, see miniextendr-engine.
§Quick start
use miniextendr_api::miniextendr;
#[miniextendr]
fn add(a: i32, b: i32) -> i32 {
a + b
}That’s it — #[miniextendr] handles everything. Items self-register
at link time; miniextendr_init! generates the R_init_* function
that calls package_init() to register all routines with R.
Wrapper R code is produced from Rust doc comments (roxygen tags are
extracted) by the cdylib-based wrapper generator and committed into
R/miniextendr_wrappers.R so CRAN builds do not require codegen.
§Choosing the right API
miniextendr has several places where two or more APIs reach the same goal with different tradeoffs — a stricter / safer / more validated option, and a looser / easier / less protective one. The most common pairs are:
| I’m reaching for… | Consider also | Why |
|---|---|---|
default IntoR for i64 / u64 / isize / usize (silently widens to REALSXP on overflow) | #[miniextendr(strict)] → crate::strict helpers (panic on overflow) | strict catches the truncation bugs caused by R having no native 64-bit integer type |
Coerce (infallible widening) | TryCoerce (fallible) | the source range can exceed the target type |
Rf_*_unchecked FFI | checked variants | unchecked is only safe inside ALTREP callbacks, with_r_unwind_protect, or with_r_thread — MXL301 lint enforces |
panic!(msg) | miniextendr_api::error!("msg", class = "...") | typed conditions let R-side tryCatch handlers route by class |
raw _dots: &Dots | #[miniextendr(dots = typed_list!(...))] | validation moves from runtime to macro call site |
#[derive(AltrepInteger)] field-based | #[altrep(manual)] + handwritten traits | when custom storage or computed-on-access can’t fit the derive |
hand-rolled TryFromSexp + IntoR | #[derive(RSerializeNative)] (serde feature) | serde is ergonomic for nested structs; hand-rolled is zero-overhead and fully controlled |
Project-wide defaults are controlled by mutually-exclusive cargo features — see the “Project-wide Defaults” feature table below.
§Default opinion
When in doubt, pick the stricter path. The framework’s default stance is “fail loudly, leave a trail.” The looser variants exist for cases where the cost is measured or the looser semantics are correct for your data — they are not the default.
§GC protection and ownership
R’s garbage collector can reclaim any SEXP that isn’t protected. miniextendr provides three complementary protection mechanisms:
| Strategy | Module | Lifetime | Release Order | Use Case |
|---|---|---|---|---|
| PROTECT stack | gc_protect | Within .Call | LIFO (stack) | Temporary allocations |
| VECSXP pool | protect_pool | Across .Calls | Any order | Long-lived R objects |
| R ownership | ExternalPtr | Until R GCs | R decides | Rust data owned by R |
Quick guide:
Temporary allocations during computation -> ProtectScope
unsafe fn compute(x: SEXP) -> SEXP {
let scope = ProtectScope::new();
let temp = scope.protect(Rf_allocVector(REALSXP, 100));
// ... work with temp ...
result.into_raw()
} // UNPROTECT(n) called automaticallyR objects surviving across .Calls -> ProtectPool or R_PreserveObject
// ProtectPool: O(1) insert/release with generational keys
let mut pool = unsafe { ProtectPool::new(16) };
let key = unsafe { pool.insert(backing_vec) };
// ... use across multiple .Calls ...
unsafe { pool.release(key) };Rust data owned by R -> ExternalPtr
#[miniextendr]
fn create_model() -> ExternalPtr<MyModel> {
ExternalPtr::new(MyModel::new())
} // R owns it; Drop runs when R GCsNote: ALTREP trait methods receive raw SEXP pointers from R’s runtime. These are safe to dereference because R guarantees valid SEXPs in ALTREP callbacks.
§Threading and safety
R uses longjmp for errors, which can bypass Rust destructors. The default
pattern is to run Rust logic on a worker thread and marshal R API calls back
to the main R thread via with_r_thread. Most FFI wrappers are
main-thread routed via #[r_ffi_checked]. Use unchecked variants only when
you have arranged a safe context.
With the nonapi feature, miniextendr can disable R’s stack checking to allow
calls from other threads. R is still not thread-safe; serialize all R API use.
§Feature Flags
§Core Features
| Feature | Description |
|---|---|
nonapi | Non-API R symbols (stack controls, mutable DATAPTR). May break with R updates. |
rayon | Parallel iterators via Rayon. Adds RParallelIterator, RParallelExtend. |
connections | Experimental R connection framework. Unstable R API. |
indicatif | Progress bars routed through R connections. Requires nonapi + connections. |
vctrs | vctrs class construction (new_vctr, new_rcrd, new_list_of) and #[derive(Vctrs)]. |
worker-thread | Worker thread for panic isolation and Drop safety. Without it, stubs run inline. |
§Type Conversions (Scalars & Vectors)
| Feature | Rust Type | R Type | Notes |
|---|---|---|---|
either | Either<L, R> | Tries L then R | Union-like dispatch |
uuid | Uuid, Vec<Uuid> | character | UUID ↔ string |
regex | Regex | character(1) | Compiles pattern from R |
url | Url, Vec<Url> | character | Validated URLs |
time | OffsetDateTime, Date | POSIXct, Date | Date/time conversions |
ordered-float | OrderedFloat<f64> | numeric | NaN-orderable floats |
num-bigint | BigInt, BigUint | character | Arbitrary precision via strings |
rust_decimal | Decimal | character | Fixed-point decimals |
num-complex | Complex<f64> | complex | Native R complex support |
indexmap | IndexMap<String, T> | named list | Preserves insertion order |
bitflags | RFlags<T> | integer | Bitflags ↔ integer |
bitvec | RBitVec | logical | Bit vectors ↔ logical |
tinyvec | TinyVec<[T; N]>, ArrayVec<[T; N]> | vectors | Small-vector optimization |
§Matrix & Array Libraries
| Feature | Types | Conversions |
|---|---|---|
ndarray | Array1–Array6, ArrayD, views | R vectors/matrices ↔ ndarray |
nalgebra | DVector, DMatrix | R vectors/matrices ↔ nalgebra |
§Serialization
| Feature | Traits/Modules | Description |
|---|---|---|
serde | RSerializeNative, RDeserializeNative | Direct Rust ↔ R native serialization |
serde_json | RSerialize, RDeserialize | JSON string serialization (includes serde) |
borsh | Borsh<T> | Binary serialization ↔ raw vectors via Borsh |
§Adapter Traits (Generic Operations)
| Feature | Traits | Use Case |
|---|---|---|
num-traits | RNum, RSigned, RFloat | Generic numeric operations |
bytes | RBuf, RBufMut | Byte buffer operations |
§Text & Data Processing
| Feature | Types/Functions | Description |
|---|---|---|
aho-corasick | AhoCorasick, aho_compile | Fast multi-pattern string search |
toml | TomlValue, toml_from_str | TOML parsing and serialization |
tabled | table_to_string | ASCII/Unicode table formatting |
sha2 | sha256_str, sha512_bytes | Cryptographic hashing |
blake3 | blake3_str, blake3_bytes | BLAKE3 hashing (fast, 32-byte digests) |
md5 | md5_str, md5_bytes | MD5 hashing (interop only — broken crypto) |
globset | GlobSet, build_globset | Shell-style glob matching (path-aware) |
zstd | zstd_compress, zstd_decompress | zstd whole-buffer compression |
§Random Number Generation
| Feature | Types | Description |
|---|---|---|
rand | RRng, RDistributions | Wraps R’s RNG with rand traits |
rand_distr | Re-exports rand_distr | Additional distributions (Normal, Exp, etc.) |
§Binary Data
| Feature | Types | Description |
|---|---|---|
raw_conversions | Raw<T>, RawSlice<T> | POD types ↔ raw vectors via bytemuck |
§Project-wide Defaults (mutually exclusive where noted)
| Feature | Description |
|---|---|
r6-default | Default class system: R6 (mutually exclusive with s7-default) |
s7-default | Default class system: S7 (mutually exclusive with r6-default) |
worker-default | Default to worker thread dispatch (implies worker-thread) |
strict-default | Default to strict mode for lossy integer conversions |
coerce-default | Default to coerce mode for type conversions |
§Development / Diagnostics
| Feature | Description |
|---|---|
doc-lint | Warn on roxygen doc comment mismatches (enabled by default) |
macro-coverage | Expose macro coverage test module for cargo expand auditing |
growth-debug | Track and report collection growth events (zero-cost when off) |
Re-exports§
pub use linkme;👻pub use miniextendr_macros::__mx_trait_impl_expand;👻pub use sexp::SEXP;pub use sexp::SEXPREC;pub use sexp_ext::SexpExt;pub use sexp_types::R_CFinalizer_t;pub use sexp_types::R_xlen_t;pub use sexp_types::RLogical;pub use sexp_types::RNativeType;pub use sexp_types::Rboolean;pub use sexp_types::Rbyte;pub use sexp_types::Rcomplex;pub use sexp_types::SEXPTYPE;pub use sexp_types::cetype_t;pub use altrep_data::AltComplexData;pub use altrep_data::AltIntegerData;pub use altrep_data::AltListData;pub use altrep_data::AltLogicalData;pub use altrep_data::AltRawData;pub use altrep_data::AltRealData;pub use altrep_data::AltStringData;pub use altrep_data::AltrepDataptr;pub use altrep_data::AltrepExtract;pub use altrep_data::AltrepLen;pub use altrep_data::IterComplexData;pub use altrep_data::IterIntCoerceData;pub use altrep_data::IterIntData;pub use altrep_data::IterIntFromBoolData;pub use altrep_data::IterListData;pub use altrep_data::IterLogicalData;pub use altrep_data::IterRawData;pub use altrep_data::IterRealCoerceData;pub use altrep_data::IterRealData;pub use altrep_data::IterState;pub use altrep_data::IterStringData;pub use altrep_data::Logical;pub use altrep_data::Sortedness;pub use altrep_data::SparseIterComplexData;pub use altrep_data::SparseIterIntData;pub use altrep_data::SparseIterLogicalData;pub use altrep_data::SparseIterRawData;pub use altrep_data::SparseIterRealData;pub use altrep_data::SparseIterState;pub use altrep_data::StreamingIntData;pub use altrep_data::StreamingRealData;pub use altrep_data::WindowedIterIntData;pub use altrep_data::WindowedIterRealData;pub use altrep_data::WindowedIterState;pub use altrep::RBase;pub use altrep_sexp::AltrepSexp;pub use altrep_sexp::ensure_materialized;pub use altrep_traits::AltrepGuard;pub use into_r::Altrep;pub use into_r::IntoR;pub use into_r::IntoRAltrep;pub use into_r_error::IntoRError;pub use newtype::FromRNewtype;pub use newtype::IntoRNewtype;pub use newtype::IntoRVecElement;pub use into_r_as::IntoRAs;pub use into_r_as::StorageCoerceError;pub use worker::Sendable;pub use worker::is_r_main_thread;pub use worker::with_r_thread;pub use worker::miniextendr_runtime_init;pub use thread::DEFAULT_R_STACK_SIZE;pub use thread::RThreadBuilder;pub use ffi_guard::GuardMode;pub use ffi_guard::guarded_ffi_call;pub use ffi_guard::guarded_ffi_call_with_fallback;pub use dataframe::DataFrame;pub use dataframe::DataFrameError;pub use dataframe::FromDataFrame;pub use dataframe::GroupKey;pub use dataframe::GroupedDataFrame;pub use dataframe::IntoDataFrame;pub use dataframe::NamedDataFrameListBuilder;pub use dataframe::group_rows;pub use dataframe_builder::RDataFrameBuilder;pub use error::r_warning;pub use rng::RngGuard;pub use rng::with_rng;pub use from_r::SexpError;pub use from_r::SexpLengthError;pub use from_r::SexpNaError;pub use from_r::SexpTypeError;pub use from_r::TryFromSexp;pub use expression::RCall;pub use expression::REnv;pub use expression::RSymbol;pub use expression::r_eval_str;pub use expression::r_eval_str_global;pub use coerce::Coerce;pub use coerce::CoerceError;pub use coerce::Coerced;pub use coerce::TryCoerce;pub use r_coerce::RCoerceCharacter;pub use r_coerce::RCoerceComplex;pub use r_coerce::RCoerceDataFrame;pub use r_coerce::RCoerceDate;pub use r_coerce::RCoerceEnvironment;pub use r_coerce::RCoerceError;pub use r_coerce::RCoerceFactor;pub use r_coerce::RCoerceFunction;pub use r_coerce::RCoerceInteger;pub use r_coerce::RCoerceList;pub use r_coerce::RCoerceLogical;pub use r_coerce::RCoerceMatrix;pub use r_coerce::RCoerceNumeric;pub use r_coerce::RCoercePOSIXct;pub use r_coerce::RCoerceRaw;pub use r_coerce::RCoerceVector;pub use r_coerce::SUPPORTED_AS_GENERICS;pub use r_coerce::is_supported_as_generic;pub use condition::AsRError;pub use condition::RCondition;pub use rvalue::RValue;pub use convert::AsDataFrame;pub use convert::AsDataFrameExt;pub use convert::AsDisplay;pub use convert::AsDisplayVec;pub use convert::AsExternalPtr;pub use convert::AsExternalPtrExt;pub use convert::AsFromStr;pub use convert::AsFromStrVec;pub use convert::AsList;pub use convert::AsListExt;pub use convert::AsNamedList;pub use convert::AsNamedListExt;pub use convert::AsNamedVector;pub use convert::AsNamedVectorExt;pub use convert::AsRNative;pub use convert::AsRNativeExt;pub use convert::Collect;pub use convert::CollectNA;pub use convert::CollectNAInt;pub use convert::CollectStrings;pub use convert::ColumnSource;pub use into_r::Lazy;pub use list::IntoList;pub use list::List;pub use list::ListAccumulator;pub use list::ListBuilder;pub use list::ListMut;pub use list::NamedList;pub use list::TryFromList;pub use list::collect_list;pub use missing::Missing;pub use missing::is_missing_arg;pub use named_vector::AtomicElement;pub use named_vector::NamedVector;pub use rcow::RBorrow;pub use rcow::RCow;pub use strvec::ProtectedStrVec;pub use strvec::ProtectedStrVecCowIter;pub use strvec::ProtectedStrVecIter;pub use strvec::StrVec;pub use strvec::StrVecBuilder;pub use strvec::StrVecCowIter;pub use strvec::StrVecIter;pub use typed_list::TypeSpec;pub use typed_list::TypedEntry;pub use typed_list::TypedList;pub use typed_list::TypedListError;pub use typed_list::TypedListSpec;pub use typed_list::actual_type_string;pub use typed_list::sexptype_name;pub use typed_list::validate_list;pub use externalptr::ErasedExternalPtr;pub use externalptr::ExternalPtr;pub use externalptr::ExternalSlice;pub use externalptr::IntoExternalPtr;pub use externalptr::TypedExternal;pub use externalptr::altrep_data1_as;pub use externalptr::altrep_data1_as_unchecked;pub use externalptr::altrep_data1_mut;pub use externalptr::altrep_data1_mut_unchecked;pub use externalptr::altrep_data2_as;pub use externalptr::altrep_data2_as_unchecked;pub use gc_protect::OwnedProtect;pub use gc_protect::ProtectIndex;pub use gc_protect::ProtectScope;pub use gc_protect::Protected;pub use gc_protect::Protector;pub use gc_protect::ReprotectSlot;pub use gc_protect::Root;pub use protect_pool::ProtectKey;pub use protect_pool::ProtectPool;pub use refcount_protect::ArenaGuard;pub use refcount_protect::RefCountedArena;pub use refcount_protect::ThreadLocalArena;pub use allocator::RAllocator;pub use abi::mx_base_vtable;pub use abi::mx_erased;pub use abi::mx_meth;pub use abi::mx_tag;pub use trait_abi::TraitView;pub use adapter_traits::RClone;pub use adapter_traits::RCopy;pub use adapter_traits::RDebug;pub use adapter_traits::RDefault;pub use adapter_traits::RDisplay;pub use adapter_traits::RError;pub use adapter_traits::RExtend;pub use adapter_traits::RFromIter;pub use adapter_traits::RFromStr;pub use adapter_traits::RHash;pub use adapter_traits::RIterator;pub use adapter_traits::RMakeIter;pub use adapter_traits::ROrd;pub use adapter_traits::RPartialOrd;pub use adapter_traits::RToVec;pub use rarray::RArray;pub use rarray::RArray3D;pub use rarray::RMatrix;pub use rarray::RVector;pub use match_arg::MatchArg;pub use match_arg::MatchArgError;pub use match_arg::choices_sexp;pub use match_arg::match_arg_from_sexp;pub use match_arg::match_arg_vec_from_sexp;pub use match_arg::match_arg_vec_into_sexp;pub use factor::Factor;pub use factor::FactorMut;pub use factor::FactorOptionVec;pub use factor::FactorVec;pub use factor::RFactor;pub use factor::UnitEnumFactor;pub use factor::build_factor;pub use factor::build_levels_sexp;pub use factor::build_levels_sexp_cached;pub use factor::factor_from_sexp;
Modules§
- abi
- ABI types for cross-package trait dispatch.
- adapter_
traits - Built-in adapter traits for std library traits.
- allocator
- R-backed global allocator for Rust.
- altrep
- Core ALTREP types and registration traits.
- altrep_
bridge - Unsafe ALTREP trampolines and installers bridging safe traits to R’s C ABI.
- altrep_
data - High-level ALTREP data traits.
- altrep_
ext - Extension trait for SEXP providing ALTREP-specific accessors.
- altrep_
impl - ALTREP implementation utilities.
- altrep_
registration 👻 - altrep_
sexp AltrepSexp— a!Send + !Syncwrapper for ALTREP vectors.- altrep_
traits - Safe, idiomatic ALTREP trait hierarchy mirroring R’s method tables.
- backtrace
- Configurable panic hook for miniextendr-based R packages.
- cached_
class - Cached R class attribute SEXPs.
- coerce
- Type coercion traits for converting Rust types to R native types.
- condition
- Condition macros and signal enum for the Rust→R condition pipeline.
- convert
- Wrapper helpers to force specific
IntoRrepresentations. - dataframe
- The unified owned R
data.frametype and its conversion traits. - dataframe_
builder - Closure-per-column
DataFramebuilder. - dots
- Support for R
...arguments represented as a validated list. R’s...(variadic arguments) support. - encoding
- Encoding / locale probing utilities.
- error
- Error handling helpers for R API calls.
- error_
value - Tagged condition value transport.
- expression
- Safe wrappers for R expression evaluation.
- externalptr
ExternalPtr<T>— a Box-like owned pointer that wraps R’s EXTPTRSXP.- externalptr_
std TypedExternalimplementations for standard library types.- factor
- Factor support for enum ↔ R factor conversions.
- ffi_
guard - Unified FFI guard for catching panics at Rust-R boundaries.
- from_r
- Conversions from R SEXP to Rust types.
- gc_
protect - GC protection tools built on R’s PROTECT stack.
- init
- Package initialization (
miniextendr_init!support). - into_r
- Conversions from Rust types to R SEXP.
- into_
r_ as - Storage-directed conversion to R.
- into_
r_ error - Error types for fallible
IntoRconversions. - list
- Thin wrapper around R list (
VECSXP). - markers
- Marker traits for proc-macro derived types. Marker traits for proc-macro derived types.
- match_
arg match.arg-style string conversion for enums.- missing
- Support for R’s missing arguments.
- mx_abi
- C-callable mx_abi functions (mx_wrap, mx_get, mx_query, mx_abi_register).
- named_
vector - Named atomic vector wrapper for HashMap/BTreeMap ↔ named R atomic vector conversions.
- newtype
- Container conversions for forwarding newtypes (
#[derive(TryFromSexp)]/#[derive(IntoR)]). See the module docs and issue #844. Container conversions for forwarding newtypes. - optionals
- Optional feature integrations with third-party crates.
- panic_
telemetry - Structured panic telemetry for debugging Rust panics that become R errors.
- prelude
- Convenience re-exports for common miniextendr items.
- protect_
pool - VECSXP-backed protection pool with generational keys.
- pump
WorkerPump<T>— safe main/worker thread coordination for FFI bodies.- r_
coerce - Traits for R’s
as.<class>()coercion functions. - r_
memory - Utilities for recovering R SEXPs from raw data pointers.
- rarray
- N-dimensional R arrays with const generic dimension count. N-dimensional R arrays with const generic dimension count.
- rcow
RCow— an R-aware copy-on-write slice.- refcount_
protect - Reference-counted GC protection using a
BTreeMap+ VECSXP backing. - registry
- Automatic registration internals.
- rng
- RNG (Random Number Generation) utilities for R interop.
- rvalue
RValue— an owned,Send, R-native value tree.- s4_
helpers - S4 slot access and class checking helpers.
- sexp
- The
SEXPnewtype and inherent methods. TheSEXPnewtype and its inherent methods. - sexp_
ext SexpExt— the ergonomic extension trait onSEXP.SexpExt— the ergonomic extension trait onSEXP.- sexp_
types - Core type vocabulary for R values:
SEXPTYPE,R_xlen_t,Rcomplex,RLogical,Rboolean,RNativeType,cetype_t. Core type vocabulary for R values:SEXPTYPE,R_xlen_t,Rbyte,Rcomplex,RLogical,Rboolean,cetype_t,R_CFinalizer_t, and theRNativeTypemarker trait + impls. - strict
- Strict conversion helpers for
#[miniextendr(strict)]. - strvec
- Thin wrapper around R character vector (
STRSXP). - sys
- Raw R FFI bindings —
extern "C-unwind"blocks forRf_*/R_*/INTEGER/ etc., plus the ALTREP method type aliases undersys::altrep. The escape hatch for code that genuinely needs the raw R C API. - thread
- Thread safety utilities for calling R from non-main threads.
- trait_
abi - Runtime support for trait ABI operations.
- typed_
list - Typed list validation for structured R list arguments.
- unwind_
protect - Safe API for R’s
R_UnwindProtect - wasm_
registry_ writer - Host-time generator of
wasm_registry.rs— the WASM-side replacement for linkme. See the module for full rationale. - worker
- Worker thread infrastructure for safe Rust-R FFI.
Macros§
- __
impl_ 👻alt_ elt - Shared
eltimplementation for ALTREP families with direct element access. - __
impl_ 👻alt_ family - Internal macro: the per-family knob matrix.
- __
impl_ 👻alt_ from_ data - Internal macro: canonical ALTREP emission.
- __
impl_ 👻alt_ get_ region - Shared
get_regionimplementation for ALTREP families. - __
impl_ 👻alt_ is_ sorted - Shared
is_sortedimplementation for ALTREP families. - __
impl_ 👻alt_ no_ na - Shared
no_naimplementation for ALTREP families. - __
impl_ 👻altcomplex_ methods - Internal macro: impl AltComplex methods (elt, get_region)
- __
impl_ 👻altinteger_ methods - Internal macro for AltInteger method implementations.
- __
impl_ 👻altlogical_ methods - Internal macro: impl AltLogical methods from AltLogicalData
- __
impl_ 👻altraw_ methods - Internal macro for AltRaw method implementations.
- __
impl_ 👻altreal_ methods - Internal macro for AltReal method implementations.
- __
impl_ 👻altrep_ base - Internal macro: impl Altrep with just length, optionally plus serialization.
- __
impl_ 👻altstring_ methods - Internal macro for AltString method implementations.
- __
impl_ 👻altvec_ complex_ dataptr - Internal macro: materializing dataptr for complex ALTREP.
- __
impl_ 👻altvec_ dataptr - Internal macro: impl AltVec with dataptr support
- __
impl_ 👻altvec_ extract_ subset - Internal macro: impl AltVec with extract_subset support
- __
impl_ 👻altvec_ flavor - Internal macro: emit the
impl AltVecfor a given flavor. - __
impl_ 👻altvec_ integer_ dataptr - Internal macro: materializing dataptr for integer ALTREP.
- __
impl_ 👻altvec_ logical_ dataptr - Internal macro: materializing dataptr for logical ALTREP.
- __
impl_ 👻altvec_ materializing_ dataptr - Internal macro: impl AltVec with a materializing dataptr for a given element type.
- __
impl_ 👻altvec_ raw_ dataptr - Internal macro: materializing dataptr for raw ALTREP.
- __
impl_ 👻altvec_ real_ dataptr - Internal macro: materializing dataptr for real ALTREP.
- __
impl_ 👻altvec_ string_ dataptr - Internal macro: impl AltVec with dataptr support for string ALTREP.
- __
impl_ 👻inferbase - Parametric implementation of
InferBasefor any ALTREP family. - __
mx_ 👻condition_ data - Internal: normalise a macro
data = ...argument intoOption<ConditionData>. Not part of the public API. - __
mx_ 👻impl_ RClone - __
mx_ 👻impl_ RCopy - __
mx_ 👻impl_ RDebug - __
mx_ 👻impl_ RDefault - __
mx_ 👻impl_ RDisplay - __
mx_ 👻impl_ RError - __
mx_ 👻impl_ RFrom Str - __
mx_ 👻impl_ RHash - __
mx_ 👻impl_ ROrd - __
mx_ 👻impl_ RPartial Ord - _linkme_
macro_ 👻MX_ ALTREP_ REGISTRATIONS - _linkme_
macro_ 👻MX_ CALL_ DEFS - _linkme_
macro_ 👻MX_ CLASS_ NAMES - _linkme_
macro_ 👻MX_ MATCH_ ARG_ CHOICES - _linkme_
macro_ 👻MX_ MATCH_ ARG_ PARAM_ DOCS - _linkme_
macro_ 👻MX_ R_ WRAPPERS - _linkme_
macro_ 👻MX_ S7_ SIDECAR_ PROPS - _linkme_
macro_ 👻MX_ TRAIT_ DISPATCH - condition
- Signal a generic R condition from Rust with
rust_conditionclass layering. - error
- Raise an R error from Rust with
rust_errorclass layering. - impl_
altcomplex_ from_ data - Generate ALTREP trait implementations for a type that implements AltComplexData.
- impl_
altcomplex_ from_ data_ generic - Generic form of
impl_altcomplex_from_data!— seeimpl_altinteger_from_data_generic!for the calling convention. - impl_
altinteger_ from_ data - Generate ALTREP trait implementations for a type that implements AltIntegerData.
- impl_
altinteger_ from_ data_ generic - Generic form of
impl_altinteger_from_data!: accepts an optional generic parameter list and where-clause ({T, U} Foo<T, U> {T: Bound, ..}) so it can targetstruct Foo<T> { .. }types, not just concrete/monomorphic ones. The non-generic macro above forwards here with empty{}brackets so there is exactly one emission body for both call shapes. - impl_
altlist_ from_ data - Generate ALTREP trait implementations for a type that implements AltListData.
- impl_
altlist_ from_ data_ generic - Generic form of
impl_altlist_from_data!: accepts an optional generic parameter list and where-clause so it can targetstruct Foo<T> { .. }types, not just concrete ones. The non-generic macro above forwards here with empty{}brackets so there is exactly one emission body. - impl_
altlogical_ from_ data - Generate ALTREP trait implementations for a type that implements AltLogicalData.
- impl_
altlogical_ from_ data_ generic - Generic form of
impl_altlogical_from_data!— seeimpl_altinteger_from_data_generic!for the calling convention. - impl_
altraw_ from_ data - Generate ALTREP trait implementations for a type that implements AltRawData.
- impl_
altraw_ from_ data_ generic - Generic form of
impl_altraw_from_data!— seeimpl_altinteger_from_data_generic!for the calling convention. - impl_
altreal_ from_ data - Generate ALTREP trait implementations for a type that implements AltRealData.
- impl_
altreal_ from_ data_ generic - Generic form of
impl_altreal_from_data!— seeimpl_altinteger_from_data_generic!for the calling convention. - impl_
altstring_ from_ data - Generate ALTREP trait implementations for a type that implements AltStringData.
- impl_
altstring_ from_ data_ generic - Generic form of
impl_altstring_from_data!— seeimpl_altinteger_from_data_generic!for the calling convention. - impl_
inferbase_ complex - Implement
InferBasefor a complex ALTREP data type. Seeimpl_inferbase_integer!for the generic calling convention. - impl_
inferbase_ integer - Implement
InferBasefor an integer ALTREP data type. - impl_
inferbase_ list - Implement
InferBasefor a list ALTREP data type. Seeimpl_inferbase_integer!for the generic calling convention. - impl_
inferbase_ logical - Implement
InferBasefor a logical ALTREP data type. Seeimpl_inferbase_integer!for the generic calling convention. - impl_
inferbase_ raw - Implement
InferBasefor a raw ALTREP data type. Seeimpl_inferbase_integer!for the generic calling convention. - impl_
inferbase_ real - Implement
InferBasefor a real ALTREP data type. Seeimpl_inferbase_integer!for the generic calling convention. - impl_
inferbase_ string - Implement
InferBasefor a string ALTREP data type. Seeimpl_inferbase_integer!for the generic calling convention. - impl_
option_ try_ from_ sexp - Implement
TryFromSexp for Option<T>where T already implements TryFromSexp. - impl_
typed_ external - Generate
TypedExternalandIntoExternalPtrimpls for a concrete monomorphization of a generic type. - impl_
vec_ option_ try_ from_ sexp_ list - Implement
TryFromSexp for Vec<Option<T>>from R list (VECSXP). - impl_
vec_ try_ from_ sexp_ list - Implement
TryFromSexp for Vec<T>from R list (VECSXP). - list
- Construct an R list from Rust values.
- message
- Emit an R message from Rust with
rust_messageclass layering. - miniextendr_
init - Generate the
R_init_*entry point for a miniextendr R package. - r
- Evaluate R code written as Rust tokens, validated at compile time.
- r_print
- Print to R’s console (like
print!). - r_
println - Print to R’s console with a newline (like
println!). - r_str
- Parse and evaluate runtime R source from Rust.
- report_
growth - Print and reset all growth counters.
- track_
growth - Track a collection growth (reallocation) event.
- try_
from_ sexp_ via_ str_ parse - Implement the four string-parse
TryFromSexpimpls (T,Option<T>,Vec<T>,Vec<Option<T>>) for a type parsed from an R character vector. - typed_
dataframe - Define a compile-time-validated wrapper for an R
data.frameinput. - typed_
list - Create a
TypedListSpecfor validating...arguments or lists. - warning
- Raise an R warning from Rust with
rust_warningclass layering.
Structs§
- Altrep
PkgName 👻 - Returns the current ALTREP package name as a C string pointer. This is set by the C entrypoint before ALTREP registration.
Statics§
- ALTREP_
DLL_ 🔒INFO - ALTREP_
PKG_ 👻NAME - Opaque handle for ALTREP package name.
Use
ALTREP_PKG_NAME.as_ptr()to get the C string pointer. - ALTREP_
PKG_ 🔒NAME_ PTR
Functions§
- altrep_
dll_ 👻info - Get the stored DllInfo pointer for ALTREP class registration.
- miniextendr_
set_ 👻 ⚠altrep_ pkg_ name - Set the ALTREP package name. Called from C entrypoint.
- set_
altrep_ 👻dll_ info - Store the DllInfo pointer during package init.
Attribute Macros§
- miniextendr
- Export Rust items to R.
- r_
ffi_ checked - Generate thread-safe wrappers for R FFI functions.
Derive Macros§
- Altrep
- Derive ALTREP registration for a data struct.
- Altrep
Complex - Derive macro for ALTREP complex vector data types.
- Altrep
Integer - Derive macro for ALTREP integer vector data types.
- Altrep
List - Derive macro for ALTREP list vector data types.
- Altrep
Logical - Derive macro for ALTREP logical vector data types.
- Altrep
Raw - Derive macro for ALTREP raw vector data types.
- Altrep
Real - Derive macro for ALTREP real vector data types.
- Altrep
String - Derive macro for ALTREP string vector data types.
- Data
Frame Row - Derive
DataFrameRow: generates a companion*DataFrametype with collection fields, plusIntoR/TryFromSexp/IntoDataFrameimpls for seamless R data.frame conversion. - External
Ptr - Derive macro for implementing
TypedExternalon a type. - Into
List - Derive
IntoListfor a struct (Rust → R list). - IntoR
- Derive
IntoRfor a single-field newtype: forward the Rust → R conversion to the inner type. - Match
Arg - Derive
MatchArg: enables conversion between Rust enums and R character strings withmatch.argsemantics (partial matching, informative errors). - Prefer
Data Frame - Derive
PreferDataFrame: when a type implements bothIntoDataFrame(viaDataFrameRow) and other conversion paths, this selects data.frame as the defaultIntoRconversion. - Prefer
External Ptr - Derive
PreferExternalPtr: when a type implements bothExternalPtrand other conversion paths (e.g.,IntoList), this selectsExternalPtrwrapping as the defaultIntoRconversion. - Prefer
List - Derive
PreferList: emits anIntoRimpl selecting list as the type’s default Rust→R conversion (viaIntoList::into_list). - PreferR
Native Type - Derive
PreferRNativeType: when a newtype wraps anRNativeTypeand also implements other conversions, this selects the native R vector conversion as the defaultIntoRpath. - RFactor
- Derive
RFactor: enables conversion between Rust enums and R factors. - RNative
Type - Derive macro for implementing
RNativeTypeon a newtype wrapper. - TryFrom
List - Derive
TryFromListfor a struct (R list → Rust). - TryFrom
Sexp - Derive
TryFromSexpfor a single-field newtype: forward the R → Rust conversion to the inner type.