Skip to main content

TraitMethod

Struct TraitMethod 

Source
struct TraitMethod {
Show 19 fields ident: Ident, sig: Signature, has_self: bool, is_mut: bool, worker: bool, unsafe_main_thread: bool, coerce: bool, check_interrupt: bool, rng: bool, unwrap_in_r: bool, param_defaults: HashMap<String, String>, param_tags: Vec<String>, skip: bool, r_name: Option<String>, strict: bool, lifecycle: Option<LifecycleSpec>, r_entry: Option<String>, r_post_checks: Option<String>, r_on_exit: Option<ROnExit>,
}
Expand description

Parsed method from a trait impl block.

Stores everything needed to generate C wrappers, R wrappers, and vtable shims for a single method in an impl Trait for Type block.

Fields§

§ident: Ident

Rust method identifier (e.g., value, increment).

§sig: Signature

Full method signature including self receiver and all parameters.

§has_self: bool

Whether the method has a receiver (&self, &mut self). False for static/associated methods.

§is_mut: bool

Whether receiver is &mut self (vs &self). Only meaningful if has_self is true.

§worker: bool

When true, dispatches to the worker thread via run_on_worker. Set by explicit #[miniextendr(worker)] or the default-worker feature flag.

§unsafe_main_thread: bool

When true, forces execution on R’s main thread via unsafe(main_thread).

§coerce: bool

Enable automatic type coercion for all parameters via Rf_coerceVector.

§check_interrupt: bool

Check for R user interrupts (R_CheckUserInterrupt) before calling the method.

§rng: bool

Enable RNG state management (GetRNGstate/PutRNGstate) around the call.

§unwrap_in_r: bool

Return Result<T, E> to R without unwrapping – R wrapper receives the result variant.

§param_defaults: HashMap<String, String>

Parameter default values from #[miniextendr(defaults(param = "value", ...))]. Keys are parameter names, values are R expressions used as default values.

§param_tags: Vec<String>

Roxygen @param tags extracted from method doc comments.

§skip: bool

When true, this method is excluded from C wrappers, R wrappers, and vtable shims. The method is still kept in the emitted impl block (it’s a real trait method).

§r_name: Option<String>

Override the R-facing method name. When set, the R wrapper uses this name instead of the Rust method name (e.g., next -> next_item to avoid R reserved words).

§strict: bool

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

§lifecycle: Option<LifecycleSpec>

Lifecycle specification for deprecation/experimental status.

§r_entry: Option<String>

R code to inject at the very top of the wrapper body.

§r_post_checks: Option<String>

R code to inject after all checks, immediately before .Call().

§r_on_exit: Option<ROnExit>

Register on.exit() cleanup code in the R wrapper.

Implementations§

Source§

impl TraitMethod

Source

fn r_method_name(&self) -> String

Returns the R-facing method name.

Uses r_name override if set, otherwise falls back to the Rust identifier string.

Source

fn c_wrapper_ident(&self, type_ident: &Ident, trait_name: &Ident) -> Ident

Generates the C wrapper function identifier: C_{Type}__{Trait}__{method}.

This is the symbol name registered with R via R_CallMethodDef for .Call() access.

Source

fn c_wrapper_ident_string( &self, type_ident: &Ident, trait_name: &Ident, ) -> String

Generates the C wrapper identifier as a String, for use in R-side .Call() generation.

Prefer c_wrapper_ident() for Rust token generation; use this variant when building R code strings (e.g., ".Call(C_Type__Trait__method, ...)").

Source

fn returns_unit(&self) -> bool

Returns true if this method has no return type (returns unit ()).

Used to decide whether the R wrapper should emit invisible(x) for void instance methods (pipe-friendly chaining).

Source

fn call_method_def_ident(&self, type_ident: &Ident, trait_name: &Ident) -> Ident

Generates the R_CallMethodDef static identifier: call_method_def_{Type}__{Trait}_{method}.

This constant holds the C function pointer and arity used by R’s .Call() registration.

Trait Implementations§

Source§

impl Clone for TraitMethod

Source§

fn clone(&self) -> TraitMethod

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TraitMethod

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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: 736 bytes