pub struct ParsedMethod {
pub ident: Ident,
pub env: ReceiverKind,
pub sig: Signature,
pub vis: Visibility,
pub doc_tags: Vec<String>,
pub method_attrs: MethodAttrs,
pub param_defaults: HashMap<String, String>,
}Expand description
Parsed method from an impl block.
§Default Parameters
Default parameters are specified using method-level syntax:
#[miniextendr(defaults(param = "value", ...))]on the method
Note: Parameter-level #[miniextendr(default = "...")] syntax is only supported
for standalone functions, not impl methods (Rust language limitation).
Defaults cannot be specified for self parameters (compile error).
Fields§
§ident: IdentThe method’s name (e.g., new, get, set_value).
env: ReceiverKindHow this method receives self: &self, &mut self, by value, or not at all (static).
sig: SignatureMethod signature with the self receiver stripped. Used for C wrapper generation
where self is handled separately as a SEXP parameter.
vis: VisibilityRust visibility of the method. Non-pub methods become private in R6;
only pub methods get @export in R wrappers.
Roxygen tag lines extracted from Rust doc comments
method_attrs: MethodAttrsPer-method attributes for class system overrides. Also carries the
match_arg(...) / choices(...) / several_ok parameter annotations
via its per_param_match_arg / per_param_choices / per_param_several_ok
fields — see MethodAttrs for the parsing surface.
param_defaults: HashMap<String, String>Parameter default values from #[miniextendr(default = "...")]
Implementations§
Source§impl ParsedMethod
impl ParsedMethod
Sourcefn validate_method_attrs(
attrs: &MethodAttrs,
class_system: ClassSystem,
span: Span,
) -> Result<()>
fn validate_method_attrs( attrs: &MethodAttrs, class_system: ClassSystem, span: Span, ) -> Result<()>
Validate method attributes for the given class system. Returns an error if unsupported attributes are used.
Sourcefn split_choice_list(raw: &str) -> Vec<String>
fn split_choice_list(raw: &str) -> Vec<String>
Split a comma-separated choices list (as given to choices(param = "a, b, c"))
into individual trimmed entries. Surrounding double-quotes are tolerated so
users can spell the list either way: "a, b" or "\"a\", \"b\"".
Sourcefn parse_method_attrs(attrs: &[Attribute]) -> Result<MethodAttrs>
fn parse_method_attrs(attrs: &[Attribute]) -> Result<MethodAttrs>
Parse method attributes in #[miniextendr(class_system(…))] format.
Supported formats:
#[miniextendr(r6(ignore, constructor, finalize, private, generic = "...")]#[miniextendr(s3(ignore, constructor, generic = "..."))]#[miniextendr(s7(ignore, constructor, generic = "..."))]- etc.
Sourcefn detect_env(sig: &Signature) -> ReceiverKind
fn detect_env(sig: &Signature) -> ReceiverKind
Detect the ReceiverKind from a method’s function signature.
Inspects the first parameter to determine whether this is a static function
(None), immutable borrow (Ref), mutable borrow (RefMut), consuming
method (Value), or ExternalPtr receiver (ExternalPtrRef, ExternalPtrRefMut,
ExternalPtrValue). Handles both standard receivers (&self, &mut self) and
typed receivers (self: &Self, self: ExternalPtr<Self>, etc.).
Sourcefn sig_without_env(sig: &Signature) -> Signature
fn sig_without_env(sig: &Signature) -> Signature
Create a copy of the method signature with the self receiver removed.
The C wrapper receives self as a separate SEXP argument and extracts it
from an ErasedExternalPtr, so the receiver must not appear in the
parameter list used for SEXP-to-Rust conversion codegen.
Sourcepub fn from_impl_item(
item: ImplItemFn,
_class_system: ClassSystem,
) -> Result<Self>
pub fn from_impl_item( item: ImplItemFn, _class_system: ClassSystem, ) -> Result<Self>
Parse a method from an impl item.
Regular doc comments are auto-converted to @description for all class systems.
Sourcepub fn should_include(&self) -> bool
pub fn should_include(&self) -> bool
Returns true if this method should be included in the class.
Sourcepub fn is_private(&self) -> bool
pub fn is_private(&self) -> bool
Returns true if this method should be private in R6.
Inferred from Rust visibility: anything not pub is private.
Sourcepub fn is_constructor(&self) -> bool
pub fn is_constructor(&self) -> bool
Returns true if this is likely a constructor. Inferred from: no env + named “new” + returns Self.
Sourcepub fn is_finalizer(&self) -> bool
pub fn is_finalizer(&self) -> bool
Returns true if this is likely a finalizer. Inferred from: consumes self (by value) + doesn’t return Self.
Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Returns true if this method should be an R6 active binding. Active bindings provide property-like access (obj$name instead of obj$name()).
Sourcepub fn r_method_name(&self) -> String
pub fn r_method_name(&self) -> String
R-facing method name.
Returns r_name if set, otherwise the Rust ident as a string.
Sourcepub fn c_wrapper_ident(&self, type_ident: &Ident, label: Option<&str>) -> Ident
pub fn c_wrapper_ident(&self, type_ident: &Ident, label: Option<&str>) -> Ident
C wrapper identifier for this method.
Format: C_{Type}__{method} or C_{Type}_{label}__{method} if labeled.
Sourcepub fn lifecycle_prelude(&self, what: &str) -> Option<String>
pub fn lifecycle_prelude(&self, what: &str) -> Option<String>
Generate lifecycle prelude R code for this method, if lifecycle is specified.
The what parameter describes the method in the format appropriate for the class system:
- Env/R6:
"Type$method()" - S3:
"method.Type()" - S7:
"method()“ (dispatched generics)
Sourcepub fn returns_self(&self) -> bool
pub fn returns_self(&self) -> bool
Returns true if this method returns Self.
Sourcepub fn returns_unit(&self) -> bool
pub fn returns_unit(&self) -> bool
Returns true if this method has no return type (returns unit ()).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ParsedMethod
impl RefUnwindSafe for ParsedMethod
impl !Send for ParsedMethod
impl !Sync for ParsedMethod
impl Unpin for ParsedMethod
impl UnsafeUnpin for ParsedMethod
impl UnwindSafe for ParsedMethod
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: 1248 bytes