Skip to main content

TraitMethod

Struct TraitMethod 

Source
struct TraitMethod {
Show 29 fields inherited_signature: bool, ident: Ident, sig: Signature, invisible: Option<bool>, has_self: bool, is_mut: bool, worker: bool, unsafe_main_thread: bool, coerce: bool, check_interrupt: bool, rng: bool, unwrap_in_r: bool, serialize: bool, return_wrap: Option<ReturnWrap>, param_defaults: HashMap<String, String>, doc_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>, no_shortcut: bool, generic: Option<String>, receiver: Option<String>, no_dispatch_dots: bool, per_param: HashMap<String, ParamAttrs>, preconditions: Option<bool>,
}
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§

§inherited_signature: bool

Signature copied from declaration metadata: infer its argument types from the real method so declaration-local aliases keep their identity.

§ident: Ident

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

§sig: Signature

Full method signature including self receiver and all parameters. A return-visibility marker is already peeled (see invisible).

§invisible: Option<bool>

Return-type visibility marker (#1213): Some(true) for -> Invisible<T>, Some(false) for -> Visible<T>, stripped from sig.output. The C wrapper unwraps the newtype before conversion.

§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 worker-default 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.

§serialize: bool

Serialize the complete return value through AsSerialize<T>.

§return_wrap: Option<ReturnWrap>

Explicit class-system return wrapping.

§param_defaults: HashMap<String, String>

Parameter default values from #[miniextendr(defaults(param = "value", ...))]. Keys are Rust names, values are R expressions used as default values; the R wrapper keys them by formal (Formals::rekey).

§doc_tags: Vec<String>

The author’s roxygen tags from the method’s doc comment. The wrapper generators forward the @param lines and the page tags (see r_wrappers::own_block_page): a method-level @rdname other or @describeIn other ... puts the method’s own R wrapper block (S3 method, S4 setMethod, env/R6 namespace member, S7 shortcut, static function) on that page instead of the type’s shared @rdname <Type> page, @name replaces the generated topic name, @order the generated order, and @inheritParams / @inherit / @inheritDotParams fill the arguments. Generics and consts stay on the type page.

§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.

§no_shortcut: bool

Opt out of the per-class <ClassName>_<method> S7 fast-dispatch shortcut (set via #[miniextendr(s7(no_shortcut))]). Only meaningful for S7 trait impls; ignored by the other class systems.

§generic: Option<String>

Existing S3/S4 generic and its receiver/formals contract.

§receiver: Option<String>§no_dispatch_dots: bool§per_param: HashMap<String, ParamAttrs>

Per-parameter #[miniextendr(match_arg(...))] / choices(...) / several_ok attributes, keyed by Rust parameter name. Mirrors MethodAttrs::per_param on the inherent-impl path (miniextendr_impl.rs) so trait methods get the same match.arg() validation prelude — see TraitMethodContext::match_arg_prelude.

§preconditions: Option<bool>

The method’s own preconditions / no_preconditions (bare, #1017): the type-derived R-side checks of the parameters that do not decide for themselves (preconditions(p) / no_preconditions(p) land in Self::per_param). None defers to the impl block.

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_{crate}_{Type}__{Trait}__{method}.

This is the symbol name registered with R via R_CallMethodDef for .Call() access. Crate-prefixed for webR cross-package symbol uniqueness (#1273); shares one formatter with TraitConst and with the string variant below so the shape can’t drift across the two types × two forms.

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_crate_Type__Trait__method, ...)").

Source

fn is_invisible(&self) -> bool

Whether the R wrapper returns this method’s value with invisible() (#1213): set by an Invisible<T> return-type marker on the method. Trait methods are visible by default, void ones included.

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 hand back the receiver (x / self) for void instance methods (pipe-friendly chaining).

Source

fn returns_self(&self) -> bool

Returns true if this method returns Self (a factory/clone method).

Mirrors crate::miniextendr_impl::ParsedMethod::returns_self on the inherent-impl path. The C wrapper hands back a bare ExternalPtr (ReturnHandling::ExternalPtr); the R wrapper must re-wrap it into a classed object — see TraitMethodContext::returns_self.

Source

fn returns_result_self(&self) -> bool

Returns true if this method returns Result<Self, E>. Treated exactly like a bare Self return on the R side (the C wrapper already raised on Err, so .val is a bare ExternalPtr). Mirrors crate::miniextendr_impl::ParsedMethod::returns_result_self.

Source

fn returns_option_self(&self) -> bool

Returns true if this method returns Option<Self>. Treated exactly like a bare Self return on the R side (the C wrapper already raised on None). Mirrors crate::miniextendr_impl::ParsedMethod::returns_option_self.

Source

fn first_generic_arg_is_self(&self, wrapper: &str) -> bool

Shared helper for Self::returns_result_self / Self::returns_option_self: true when the return type is wrapper<Self, ..> (e.g. Result<Self, E> / Option<Self>).

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) -> Self

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> SizeHint for T
where T: ?Sized,

Source§

default fn lower_bound(&self) -> usize

🔬This is a nightly-only experimental API. (core_io_internals)
Returns a lower bound on the number of elements this container-like item contains. For example, an array [u8; 12] could return any value between 0 and 12 inclusively as a correct implementation. Read more
Source§

default fn upper_bound(&self) -> Option<usize>

🔬This is a nightly-only experimental API. (core_io_internals)
Returns an upper bound on the number of elements this container-like item contains if it can be determined, otherwise None. Read more
Source§

final fn size_hint(&self) -> (usize, Option<usize>)

🔬This is a nightly-only experimental API. (core_io_internals)
Returns an estimate for the number of elements this container like type contains. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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: 888 bytes