pub fn guarded_ffi_call_with_fallback<F, R>(
f: F,
fallback: R,
source: PanicSource,
) -> Rwhere
F: FnOnce() -> R,Expand description
Execute f inside a CatchUnwind guard, returning fallback on panic.
Unlike guarded_ffi_call with CatchUnwind (which diverges via Rf_error),
this variant returns the fallback value instead of raising an R error.
This is needed for connection trampolines where panicking through R/C frames
is UB but raising an R error is also undesirable (the caller expects a return
value indicating failure).
Deferred conditions are signalled on R’s main thread after the callback.
R handlers may exit (including options(warn = 2)); the Rust panic fallback
is unchanged. Finalizer callbacks must suppress conditions instead.
Telemetry is fired before returning the fallback.