Reference manual

User Manual

Comprehensive guides to miniextendr runtime behavior, build tooling, macros, and subsystem details.

  • Runtime behavior, conversion rules, macros, and build tooling in one place.
  • Pages are ordered by a suggested learning path, not just alphabetical listing.
  • Descriptions are generated from the source docs so the index is scannable.
manual scope

The reference side of the site is built for lookup speed as much as long-form reading.

70 pages in the manual
Core getting started, architecture, conversions, classes
Deep ALTREP, threading, GC protection, macros, packaging

How to use the manual

The manual is the exhaustive reference for miniextendr’s runtime, build system, derive macros, and platform-specific behavior.

Use it when you need the exact rules for a conversion, the details of an ALTREP implementation, or the packaging steps required for CRAN-compatible releases.

Full Index

Every manual page, ordered as a documentation path.

Start near the top if you are learning the framework. Jump deeper when you already know the subsystem you need.

Manual page 1

Getting Started with miniextendr

This guide walks you through creating your first R package with a Rust backend using miniextendr.

Manual page 2

Architecture Overview

This document provides a high-level overview of miniextendr for evaluators, contributors, and users comparing approaches for Rust-R interop.

Manual page 3

Type Conversions in miniextendr

This guide documents how miniextendr converts between R and Rust types, including NA handling, coercion rules, and edge cases.

Manual page 4

Class Systems in miniextendr

miniextendr supports five R class systems. This guide helps you choose the right one for your use case.

Manual page 5

Package Map

This page explains every package-like component in the repository: the core Rust crates, the excluded support tools, the R packages, and the fixture packages used to test cross-package behavior.

Manual page 6

ALTREP in miniextendr

ALTREP (Alternative Representations) is R's system for creating custom vector implementations. miniextendr provides a powerful, safe abstraction for creating ALTREP vectors from Rust.

Manual page 7

DESCRIPTION Fields for miniextendr Packages

When you inspect rpkg/DESCRIPTION or a scaffolded package such as tests/model_project/DESCRIPTION, some lines are ordinary R-package metadata and some are there specifically to support the miniextendr build flow.

Manual page 8

ExternalPtr

ExternalPtr<T> is a Box-like owned pointer that wraps R's EXTPTRSXP. It lets you hand ownership of Rust-allocated data to R and let R's garbage collector decide when to drop it.

Manual page 9

Error Handling in miniextendr

This guide covers error handling patterns, panic safety, and best practices for robust R-Rust interop.

Manual page 10

Thread Safety in miniextendr

This document explains how to safely call R APIs from threads other than the main R thread.

Manual page 11

Vendoring and CRAN Release Prep

How miniextendr packages its dependencies for CRAN offline builds.

Manual page 12

Feature Flags Reference

miniextendr-api uses Cargo feature flags to enable optional integrations. Only default features are enabled automatically.

Manual page 13

`#[miniextendr]` Attribute Reference

Complete reference for #[miniextendr] on every Rust item type.

Manual page 14

Automatic Registration & Package Initialization

This document explains how miniextendr automatically registers R-callable functions and initializes the runtime when an R package loads.

Manual page 15

Adapter Traits: Exporting External Traits to R

This guide explains how to expose Rust traits you don't own (from external crates) to R via miniextendr's trait ABI.

Manual page 16

Adapter Trait Cookbook

Practical recipes for exposing external Rust traits to R using the adapter pattern.

Manual page 17

Arrow Integration

Zero-copy conversions between R vectors and Apache Arrow arrays.

Manual page 18

Rayon Integration Guide

Miniextendr provides seamless integration with Rayon for parallel computation in R packages. This enables writing high-performance parallel code while maintaining R's safety guarantees.

Manual page 19

Safety Documentation

This document explains the thread safety invariants and FFI safety requirements for miniextendr. Read this before contributing unsafe code or modifying the worker, thread, or unwind_protect modules.

Manual page 20

GC Protection Toolkit

This document covers miniextendr's RAII-based GC protection facilities.

Manual page 21

FFI Guard and Panic Telemetry

How miniextendr catches panics at Rust-R boundaries and provides structured diagnostics.

Manual page 22

Type Coercion in miniextendr

This document describes the Coerce<R> trait system for converting Rust types to R's native scalar types.

Manual page 23

`as.<class>()` Coercion Methods

This document describes how to implement R's as.<class>() coercion generics for Rust types using the #[miniextendr(as = "...")] attribute.

Manual page 24

Conversion Behavior Matrix

This document describes how miniextendr converts between R types and Rust types. Conversions are governed by three modes (normal, coerce, strict) and apply to both directions: R-to-Rust (TryFromSexp) and Rust-to-R (IntoR).

Manual page 25

Data Frame Conversion in miniextendr

miniextendr provides comprehensive support for converting between Rust types and R data frames, with three complementary approaches offering different trade-offs between ergonomics and flexibility.

Manual page 26

Custom R Connections

R connections are the standard abstraction for I/O in R -- readLines(), writeLines(), readBin(), writeBin(), scan(), and many other functions all operate on connections. miniextendr lets you create custom R connections backed by Rust types, enabling you to expose any Rust I/O source or sink to R's connection infrastructure.

Manual page 27

Expression Evaluation Helpers

Safe wrappers for building and evaluating R function calls from Rust.

Manual page 28

Enums and Factors Guide

How to map Rust enums to R factors and character strings.

Manual page 29

Dots and typed_list! Validation

This document describes miniextendr's support for R's ... (dots) arguments and the typed_list! macro for structured validation.

Manual page 30

S3 Methods Guide

How to implement S3 generics (print, format, etc.) with #[miniextendr(s3)].

Manual page 31

ALTREP Practical Examples

Real-world examples of ALTREP usage patterns in miniextendr.

Manual page 32

ALTREP Quick Reference

One-page reference for miniextendr's ALTREP system.

Manual page 33

ALTREP Guard Modes

Controls how panics and R errors are caught in ALTREP callback trampolines.

Manual page 34

Receiving ALTREP Vectors from R

How miniextendr handles ALTREP vectors when R passes them to Rust functions.

Manual page 35

Sparse Iterator ALTREP Guide

Sparse iterator ALTREP vectors use Iterator::nth() to skip directly to requested indices, caching only the elements that are actually accessed. This makes them ideal for large vectors where only a few elements are needed.

Manual page 36

RArray: N-Dimensional R Arrays

Compile-time dimensioned wrappers for R arrays, matrices, and vectors.

Manual page 37

Raw Conversions

Convert Rust POD (Plain Old Data) types to and from R raw vectors using bytemuck.

Manual page 38

serde_r: Direct Rust-R Serialization

The serde_r feature provides direct serialization between Rust types and native R objects without going through an intermediate format like JSON. This enables efficient, type-preserving conversions that respect R's native data structures.

Manual page 39

vctrs Integration with `#[derive(Vctrs)]`

miniextendr provides the #[derive(Vctrs)] macro to create vctrs-compatible S3 vector classes from Rust structs. These types integrate seamlessly with the tidyverse ecosystem.

Manual page 40

RNG (Random Number Generation)

Safe access to R's random number generators from Rust.

Manual page 41

Encoding and Locale

This document covers miniextendr's UTF-8 locale requirement and encoding probing utilities.

Manual page 42

Lifecycle Integration

miniextendr integrates with the lifecycle R package to mark functions as experimental, deprecated, or defunct. The proc macro generates lifecycle badges, runtime warnings, and roxygen tags automatically.

Manual page 43

Strict Mode

Strict mode rejects lossy type conversions that would silently widen or truncate values. When enabled, out-of-range values panic instead of being coerced.

Manual page 44

Feature-Controlled Defaults

Project-wide defaults for #[miniextendr] options, controlled via Cargo features.

Manual page 45

Non-API R Functions Tracking

This document tracks usage of non-API R functions in miniextendr. Non-API functions are detected by R CMD check via tools:::.checksosymbols.

Manual page 46

Extending miniextendr

This guide explains how to extend miniextendr with custom types, enabling them to be passed between Rust and R.

Manual page 47

Trait ABI

The trait ABI lets R (and other packages) call Rust trait methods without knowing the concrete Rust type at compile time. It does this by storing a tiny "header + vtable" next to the object and using R external pointers to carry it around.

Manual page 48

miniextendr Trait-Based ABI Implementation Plan

This document describes the trait ABI system for cross-package trait dispatch.

Manual page 49

Linking Strategy

This document explains how miniextendr links against R's shared library (libR) for both R packages and standalone Rust binaries.

Manual page 50

R's Package Build System for Shared Libraries

How R builds packages with compiled code, and how miniextendr integrates with it.

Manual page 51

Template System

The minirextendr package provides scaffolding templates for creating new R packages with Rust backends. This document explains how the template system works and how to keep templates in sync with the reference implementation.

Manual page 52

miniextendr-engine: why it exists (and why it changed)

This file documents the rationale for the recent refactor that moved R linking and embedded-R initialization into miniextendr-engine, and made the benchmark crate (miniextendr-bench) depend on it.

Manual page 53

Calling R Package C APIs from Rust via bindgen

This document explains how to use C headers from installed R packages in a miniextendr Rust crate. The technique uses bindgen to generate Rust FFI bindings at development time, and R's standard build system to compile the required C shim files.

Manual page 54

How R's Build System Invokes Rtools (and How to Replicate It)

Open the MSYS2 UCRT64 shell that ships with Rtools45. On a default install this is:

Manual page 55

R-Backed Global Allocator

This document covers RAllocator, a Rust GlobalAlloc implementation backed by R's memory manager.

Manual page 56

Cached SEXPs

R strings (CHARSXPs), symbols, and class vectors are immutable once created. When the same value is needed repeatedly — especially on hot paths like vectorized conversions — cache it once and reuse the pointer.

Manual page 57

Prefer* Derives Guide

How to control which R representation a Rust type uses when returned from #[miniextendr] functions.

Manual page 58

`#[track_caller]` in miniextendr

The #[miniextendr] macro automatically adds #[track_caller] to Rust functions for better panic location reporting.

Manual page 59

Proc-Macro and Lint Error Guide

This guide covers common error messages from #[miniextendr] proc macros and the miniextendr-lint static analysis tool.

Manual page 60

Progress Bars in R via indicatif

miniextendr provides an adapter that routes indicatif progress bar output through R's console, so progress bars render correctly in R terminals, RStudio, and other R frontends.

Manual page 61

Environment Variables

All environment variables that affect miniextendr's build, configure, test, and lint processes.

Manual page 62

Developer Workflow

Quick reference for common development tasks. See CLAUDE.md for complete build system documentation.

Manual page 63

Maintainer Guide

This document covers maintenance tasks for the miniextendr project.

Manual page 64

Performance Benchmarks

Baseline measurements for miniextendr's runtime overhead on Apple M3 Max (macOS, Rust 1.93, R 4.5). Run date: 2026-02-18.

Manual page 65

Troubleshooting

Common issues and solutions when developing with miniextendr.

Manual page 66

Smoke Test Process

This document describes the smoke test process for the miniextendr project. It covers the full "demanding" smoke lane -- the most thorough validation pass, intended for release gates and nightly CI runs.

Manual page 67

minirextendr — Scaffolding & Workflow Helper

minirextendr is a pure-R companion package that scaffolds, builds, and maintains R packages using the miniextendr Rust-R framework. Think of it as usethis for miniextendr projects.

Manual page 68

Orphan Rule Challenges: Feature Crate Extraction

We explored extracting miniextendr-api's optional features (ndarray, nalgebra, serde, rayon, etc.) into separate miniextendr-<name> crates. The goal was to reduce miniextendr-api's surface area and let users depend only on what they need.

Manual page 69

miniextendr: Known Gaps and Limitations

This document catalogs known gaps, limitations, and undocumented behaviors in miniextendr. It serves as both user documentation and a roadmap for future improvements.

Manual page 70

Feature Backlog

This document lists practical feature candidates for upcoming maintenance cycles. Items are scoped to be incremental and compatible with the current architecture.