Expand description
§Type Conversion Helpers for Method Shims
This module provides type conversion functions used by the generated
method shims from #[miniextendr] traits. These functions wrap the existing
TryFromSexp and IntoR traits with appropriate error handling.
§Purpose
Method shims generated by #[miniextendr] traits need to:
- Convert
SEXParguments to Rust types - Convert Rust return values to SEXP
- Handle conversion errors gracefully (via R errors)
This module provides a uniform interface for these conversions.
§Error Handling
Conversion errors raise R errors (via Rf_error), which unwinds
back to R. This ensures that:
- Invalid arguments produce helpful error messages
- R’s error handling mechanism is used consistently
- No Rust panics escape to R
§Thread Safety
All functions in this module must be called on R’s main thread,
as they interact with R’s SEXP values and error handling.
Functions§
- check_
arity ⚠ - Check that the number of arguments matches expected arity.
- extract_
arg ⚠ - Extract and convert an argument from argv with bounds checking.
- from_
sexp ⚠ - Convert an R SEXP to a Rust type, aborting via
Rf_erroron failure. - nil⚠
- Return R’s
NULLvalue. - rf_
error ⚠ - Raise an R error with the given message.
- to_sexp⚠
- Convert a Rust value to an R SEXP.
- try_
from_ ⚠sexp - Convert an R SEXP to a Rust type, returning a Result.