Skip to main content

Module ffi_guard

Module ffi_guard 

Source
Expand description

Unified FFI guard for catching panics at Rust-R boundaries.

Four modules independently catch panics at FFI boundaries: worker.rs, altrep_bridge.rs, unwind_protect.rs, and connection.rs. This module extracts the common pattern into a single guarded_ffi_call function.

§Guard Modes

  • GuardMode::CatchUnwind: Wraps the closure in catch_unwind. On panic, fires telemetry and raises an R error via Rf_error (diverges). Used by worker and connection trampolines.

  • GuardMode::RUnwind: Uses R_UnwindProtect to catch both Rust panics and R longjmps. Used by ALTREP callbacks that call R APIs.

The ALTREP-specific Unsafe mode (no protection at all) stays in altrep_bridge.rs since it has no general applicability.

Enums§

GuardMode
FFI guard mode controlling how panics are caught at Rust-R boundaries.

Functions§

guarded_ffi_call
Execute f inside an FFI guard selected by mode.
guarded_ffi_call_with_fallback
Execute f inside a CatchUnwind guard, returning fallback on panic.