Skip to main content

MiniextendrFnAttrs

Struct MiniextendrFnAttrs 

Source
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 invisibly
  • check_interrupt: insert R_CheckUserInterrupt() before calling Rust
  • worker: opt into worker-thread execution (default is main thread)
  • coerce: enable automatic coercion for supported parameter types
  • rng: enable RNG state management (GetRNGstate/PutRNGstate)
  • unwrap_in_r: return Result<T, E> to R without unwrapping
  • prefer = "auto" | "list" | "externalptr" | "vector": prefer a specific IntoR path

§Note

Unknown flags are rejected with a compile error to avoid silently ignoring typos.

Fields§

§force_worker: bool

Force 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: bool

Insert R_CheckUserInterrupt() before calling the Rust function.

§coerce_all: bool

Enable automatic coercion for all parameters that support it.

§rng: bool

Enable RNG state management (GetRNGstate/PutRNGstate).

§unwrap_in_r: bool

Return Result<T, E> to R without unwrapping.

§return_pref: ReturnPref

Preferred 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: bool

Strict output conversion: panic instead of lossy widening for i64/u64/isize/usize.

§internal: bool

Mark as internal: adds @keywords internal, suppresses @export.

§noexport: bool

Suppress @export without adding @keywords internal.

§export: bool

Force @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

Source§

fn default() -> MiniextendrFnAttrs

Returns the “default value” for a type. Read more
Source§

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 prefer or c_symbol)
  • Missing required sub-options (e.g., s3(...) without class)
Source§

fn parse(input: ParseStream<'_>) -> Result<Self>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> SizedTypeProperties for T

Source§

#[doc(hidden)]
const SIZE: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const ALIGN: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const ALIGNMENT: Alignment = _

🔬This is a nightly-only experimental API. (ptr_alignment_type)
Source§

#[doc(hidden)]
const IS_ZST: bool = _

🔬This is a nightly-only experimental API. (sized_type_properties)
true if this type requires no storage. false if its size is greater than zero. Read more
Source§

#[doc(hidden)]
const LAYOUT: Layout = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const MAX_SLICE_LEN: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
The largest safe length for a [Self]. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

Layout§

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