pub(crate) struct MiniextendrFnAttrs {Show 22 fields
pub(crate) force_worker: bool,
pub(crate) force_invisible: Option<bool>,
pub(crate) check_interrupt: bool,
pub(crate) coerce_all: bool,
pub(crate) rng: bool,
pub(crate) unwrap_in_r: bool,
pub(crate) return_pref: ReturnPref,
pub(crate) s3_generic: Option<String>,
pub(crate) s3_class: Option<String>,
pub(crate) dots_spec: Option<TokenStream>,
pub(crate) dots_span: Option<Span>,
pub(crate) lifecycle: Option<LifecycleSpec>,
pub(crate) strict: bool,
pub(crate) internal: bool,
pub(crate) noexport: bool,
pub(crate) export: bool,
pub(crate) doc: Option<String>,
pub(crate) c_symbol: Option<String>,
pub(crate) r_name: Option<String>,
pub(crate) r_entry: Option<String>,
pub(crate) r_post_checks: Option<String>,
pub(crate) r_on_exit: Option<ROnExit>,
}Expand description
Parsed arguments for the #[miniextendr(...)] attribute on functions.
This is intentionally a small, “data-only” struct that:
- Owns the parsing rules for the attribute
- Produces a normalized, easy-to-consume representation for codegen
§Accepted flags
invisible/visible: control whether the generated R wrapper returns invisiblycheck_interrupt: insertR_CheckUserInterrupt()before calling Rustworker: opt into worker-thread execution (default is main thread)coerce: enable automatic coercion for supported parameter typesrng: enable RNG state management (GetRNGstate/PutRNGstate)unwrap_in_r: returnResult<T, E>to R without unwrappingprefer = "auto" | "list" | "externalptr" | "vector": prefer a specificIntoRpath
§Note
Unknown flags are rejected with a compile error to avoid silently ignoring typos.
Fields§
§force_worker: boolForce execution on worker thread (set by worker).
force_invisible: Option<bool>Override visibility; Some(true) makes the wrapper return invisibly, Some(false) forces visibility.
check_interrupt: boolInsert R_CheckUserInterrupt() before calling the Rust function.
coerce_all: boolEnable automatic coercion for all parameters that support it.
rng: boolEnable RNG state management (GetRNGstate/PutRNGstate).
unwrap_in_r: boolReturn Result<T, E> to R without unwrapping.
return_pref: ReturnPrefPreferred return conversion: forces AsList/AsExternalPtr/AsRNative wrapping
of the return value before IntoR::into_sexp is called.
s3_generic: Option<String>S3 generic name (if this function is an S3 method).
Use #[miniextendr(s3(generic = "vec_proxy", class = "my_vctr"))] to mark a function
as an S3 method for an existing generic.
s3_class: Option<String>S3 class suffix for the method (e.g., “my_vctr” or “my_vctr.my_vctr” for double-dispatch).
dots_spec: Option<TokenStream>Typed list validation spec for dots parameter.
Use #[miniextendr(dots = typed_list!(...))] to automatically validate dots
at the start of the function and bind the result to dots_typed.
dots_span: Option<Span>Span of the dots = ... attribute for error reporting.
lifecycle: Option<LifecycleSpec>Lifecycle specification for deprecation/experimental status.
strict: boolStrict output conversion: panic instead of lossy widening for i64/u64/isize/usize.
internal: boolMark as internal: adds @keywords internal, suppresses @export.
noexport: boolSuppress @export without adding @keywords internal.
export: boolForce @export even on non-pub functions. Antidote to noexport.
doc: Option<String>Custom roxygen documentation override.
When set, replaces auto-extracted roxygen from Rust doc comments.
Each \n in the string becomes a separate #' line.
c_symbol: Option<String>Custom C symbol name for the generated wrapper.
Overrides the default C_<fn_name> naming convention.
Must be a valid C identifier (alphanumeric + underscore, starting with letter or underscore).
r_name: Option<String>Override R wrapper function name.
Use #[miniextendr(r_name = "is.my_type")] to give the R wrapper a different name
than the Rust function. The C symbol is still derived from the Rust name.
Cannot be combined with s3(generic/class) — use generic/class for S3 naming.
r_entry: Option<String>R code to inject at the very top of the wrapper body (before all built-in checks).
Use #[miniextendr(r_entry = "x <- as.integer(x)")] to run R code before
missing-default handling, lifecycle checks, stopifnot, and match.arg.
Multi-line via \n. No validation of R syntax.
r_post_checks: Option<String>R code to inject after all built-in checks, immediately before .Call().
Use #[miniextendr(r_post_checks = "message('calling rust')")] to run R code
after all precondition checks but before the Rust function is invoked.
Multi-line via \n. No validation of R syntax.
r_on_exit: Option<ROnExit>Register on.exit() cleanup code in the R wrapper.
Short form: #[miniextendr(r_on_exit = "close(con)")] → on.exit(close(con), add = TRUE)
Long form: #[miniextendr(r_on_exit(expr = "close(con)", add = false))]
Defaults: add = TRUE, after = TRUE. Injected after r_entry, before other checks.
Trait Implementations§
Source§impl Default for MiniextendrFnAttrs
impl Default for MiniextendrFnAttrs
Source§fn default() -> MiniextendrFnAttrs
fn default() -> MiniextendrFnAttrs
Source§impl Parse for MiniextendrFnAttrs
Parses the comma-separated option list inside #[miniextendr(...)].
impl Parse for MiniextendrFnAttrs
Parses the comma-separated option list inside #[miniextendr(...)].
Supports three syntactic forms for each option:
- Bare identifier:
#[miniextendr(invisible)] - Name-value:
#[miniextendr(prefer = "list")]or#[miniextendr(invisible = true)] - Nested list:
#[miniextendr(s3(generic = "...", class = "..."))]
Options with negated forms (no_worker, no_coerce, no_strict) explicitly
disable the corresponding flag, which is useful for overriding feature-based
defaults.
An empty input (plain #[miniextendr]) resolves all options to their feature-based
defaults (e.g., default-worker, default-coerce, default-strict).
§Errors
Returns a compile error for:
- Unknown option names (prevents silent typos)
- Mutually exclusive options (
internal+noexport) - Invalid values for key-value options (e.g., bad
preferorc_symbol) - Missing required sub-options (e.g.,
s3(...)withoutclass)
fn parse(input: ParseStream<'_>) -> Result<Self>
Auto Trait Implementations§
impl Freeze for MiniextendrFnAttrs
impl RefUnwindSafe for MiniextendrFnAttrs
impl !Send for MiniextendrFnAttrs
impl !Sync for MiniextendrFnAttrs
impl Unpin for MiniextendrFnAttrs
impl UnsafeUnpin for MiniextendrFnAttrs
impl UnwindSafe for MiniextendrFnAttrs
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
ptr_alignment_type)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
sized_type_properties)[Self]. Read moreLayout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 384 bytes