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: boolSignature copied from declaration metadata: infer its argument types from the real method so declaration-local aliases keep their identity.
ident: IdentRust method identifier (e.g., value, increment).
sig: SignatureFull 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: boolWhether the method has a receiver (&self, &mut self).
False for static/associated methods.
is_mut: boolWhether receiver is &mut self (vs &self). Only meaningful if has_self is true.
worker: boolWhen true, dispatches to the worker thread via run_on_worker.
Set by explicit #[miniextendr(worker)] or the worker-default feature flag.
unsafe_main_thread: boolWhen true, forces execution on R’s main thread via unsafe(main_thread).
coerce: boolEnable automatic type coercion for all parameters via Rf_coerceVector.
check_interrupt: boolCheck for R user interrupts (R_CheckUserInterrupt) before calling the method.
rng: boolEnable RNG state management (GetRNGstate/PutRNGstate) around the call.
unwrap_in_r: boolReturn Result<T, E> to R without unwrapping – R wrapper receives the result variant.
serialize: boolSerialize 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).
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: boolWhen 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: boolStrict 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: boolOpt 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
impl TraitMethod
Sourcefn r_method_name(&self) -> String
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.
Sourcefn c_wrapper_ident(&self, type_ident: &Ident, trait_name: &Ident) -> Ident
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.
Sourcefn c_wrapper_ident_string(
&self,
type_ident: &Ident,
trait_name: &Ident,
) -> String
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, ...)").
Sourcefn is_invisible(&self) -> bool
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.
Sourcefn returns_unit(&self) -> bool
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).
Sourcefn returns_self(&self) -> bool
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.
Sourcefn returns_result_self(&self) -> bool
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.
Sourcefn returns_option_self(&self) -> bool
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.
Sourcefn first_generic_arg_is_self(&self, wrapper: &str) -> bool
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>).
Sourcefn call_method_def_ident(&self, type_ident: &Ident, trait_name: &Ident) -> Ident
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
impl Clone for TraitMethod
Auto Trait Implementations§
impl !Send for TraitMethod
impl !Sync for TraitMethod
impl Freeze for TraitMethod
impl RefUnwindSafe for TraitMethod
impl Unpin for TraitMethod
impl UnsafeUnpin for TraitMethod
impl UnwindSafe for TraitMethod
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> SizeHint for Twhere
T: ?Sized,
impl<T> SizeHint for Twhere
T: ?Sized,
Source§default fn lower_bound(&self) -> usize
default fn lower_bound(&self) -> usize
core_io_internals)[u8; 12] could return any value between 0 and
12 inclusively as a correct implementation. Read moreSource§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: 888 bytes