Skip to main content

ParsedImpl

Struct ParsedImpl 

Source
pub struct ParsedImpl {
Show 21 fields pub type_ident: Ident, pub class_system: ClassSystem, pub class_name: Option<String>, pub label: Option<String>, pub doc_tags: Vec<String>, pub methods: Vec<ParsedMethod>, pub original_impl: ItemImpl, pub cfg_attrs: Vec<Attribute>, pub vctrs_attrs: VctrsAttrs, pub r6_inherit: Option<String>, pub r6_portable: Option<bool>, pub r6_cloneable: Option<bool>, pub r6_lock_objects: Option<bool>, pub r6_lock_class: Option<bool>, pub s7_parent: Option<String>, pub s7_abstract: bool, pub r_data_accessors: bool, pub strict: bool, pub internal: bool, pub noexport: bool, pub param_warnings: TokenStream,
}
Expand description

Fully parsed #[miniextendr] impl block, ready for code generation.

Contains the type identity, chosen class system, all parsed methods, the original impl block (with miniextendr attrs stripped for re-emission), and all class-system-specific configuration options. Created by ParsedImpl::parse and consumed by the per-class-system R wrapper generators and generate_method_c_wrapper.

Fields§

§type_ident: Ident

The Rust type name being implemented (e.g., Counter).

§class_system: ClassSystem

Which R class system to generate wrappers for.

§class_name: Option<String>

Optional override for the R class name. When None, uses type_ident as the class name.

§label: Option<String>

Optional label for distinguishing multiple impl blocks of the same type.

§doc_tags: Vec<String>

Roxygen tag lines extracted from /// doc comments on the impl block. Used for class-level documentation (e.g., the R6 class docstring or S3 type description).

§methods: Vec<ParsedMethod>

All parsed methods in this impl block, in source order.

§original_impl: ItemImpl

The original impl block with #[miniextendr] and roxygen attrs stripped. Re-emitted as-is so the Rust compiler sees the actual method implementations.

§cfg_attrs: Vec<Attribute>

#[cfg(...)] attributes from the impl block, propagated to all generated items (C wrappers, R wrapper constants, call def arrays) for conditional compilation.

§vctrs_attrs: VctrsAttrs

vctrs-specific attributes (only used when class_system is Vctrs)

§r6_inherit: Option<String>

R6 parent class name for inheritance (e.g., "ParentClass"). Propagated from ImplAttrs::r6_inherit.

§r6_portable: Option<bool>

R6 portable flag. When Some(true), generates a portable R6 class. Propagated from ImplAttrs::r6_portable.

§r6_cloneable: Option<bool>

R6 cloneable flag. Controls whether $clone() is available on instances. Propagated from ImplAttrs::r6_cloneable.

§r6_lock_objects: Option<bool>

R6 lock_objects flag. When Some(true), prevents adding new fields after creation. Propagated from ImplAttrs::r6_lock_objects.

§r6_lock_class: Option<bool>

R6 lock_class flag. When Some(true), prevents modifying the class definition. Propagated from ImplAttrs::r6_lock_class.

§s7_parent: Option<String>

S7 parent class name for inheritance (e.g., "ParentClass"). Propagated from ImplAttrs::s7_parent.

§s7_abstract: bool

When true, marks this as an abstract S7 class that cannot be instantiated. Propagated from ImplAttrs::s7_abstract.

§r_data_accessors: bool

When true, auto-include sidecar #[r_data] field accessors in the class definition. For R6: active bindings are added via $set("active", ...) after class creation. For S7: properties are spliced from .rdata_properties_{Type} into new_class().

§strict: bool

Strict conversion mode: methods returning lossy types use checked conversions.

§internal: bool

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

§noexport: bool

Suppress @export without adding @keywords internal.

§param_warnings: TokenStream

Deprecation warnings for @param tags found on the impl block. Appended to the final TokenStream output.

Implementations§

Source§

impl ParsedImpl

Source

pub fn parse(attrs: ImplAttrs, item_impl: ItemImpl) -> Result<Self>

Parse an impl block with class system attribute.

Note: Trait impls (impl Trait for Type) are handled by expand_impl before this function is called, so we only handle inherent impls here.

Source

pub fn class_name(&self) -> String

Get the class name (override or type name).

Source

pub fn included_methods(&self) -> impl Iterator<Item = &ParsedMethod>

Get methods that should be included.

Source

pub fn constructor(&self) -> Option<&ParsedMethod>

Get the constructor method (fn new() -> Self), if included. Respects #[...(ignore)] and visibility filters.

Source

fn is_method_constructor(&self, m: &ParsedMethod) -> bool

Class-system-aware constructor detection.

The default ParsedMethod::is_constructor requires the method to return Self. For vctrs impls that’s too strict: the canonical vctrs constructor pattern returns the underlying vector payload (e.g. Vec<f64>) which vctrs::new_vctr() then wraps — returning Self would produce an ExternalPtr that new_vctr can’t accept as .data.

Source

pub fn public_instance_methods(&self) -> impl Iterator<Item = &ParsedMethod>

Get public instance methods (have env, not private, not active).

Source

pub fn private_instance_methods(&self) -> impl Iterator<Item = &ParsedMethod>

Get private instance methods (have env, private visibility, not active).

Source

pub fn active_instance_methods(&self) -> impl Iterator<Item = &ParsedMethod>

Get active binding getter methods for R6 (have env, marked active, not setter). Active bindings provide property-like access (obj$name instead of obj$name()).

Source

pub fn active_setter_methods(&self) -> impl Iterator<Item = &ParsedMethod>

Get active binding setter methods for R6 (have env, marked as r6_setter).

Source

pub fn find_setter_for_prop(&self, prop_name: &str) -> Option<&ParsedMethod>

Find the setter method for a given property name.

Source

pub fn instance_methods(&self) -> impl Iterator<Item = &ParsedMethod>

Get instance methods (have env) - includes both public and private.

Source

pub fn static_methods(&self) -> impl Iterator<Item = &ParsedMethod>

Get static methods (no env, not constructor, not finalizer).

Source

pub fn as_coercion_methods(&self) -> impl Iterator<Item = &ParsedMethod>

Get methods with #[miniextendr(as = "...")] attribute.

These generate S3 methods for R’s as.<class>() generics like as.data.frame.MyType, as.list.MyType, etc.

Source

pub fn finalizer(&self) -> Option<&ParsedMethod>

Get the finalizer method, if any.

Source

pub fn r_wrappers_const_ident(&self) -> Ident

Module constant identifier for R wrapper parts.

Format: R_WRAPPERS_IMPL_{TYPE} or R_WRAPPERS_IMPL_{TYPE}_{LABEL} if labeled.

Source

pub fn label(&self) -> Option<&str>

Returns the label if present.

Trait Implementations§

Source§

impl Debug for ParsedImpl

Source§

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

Formats the value using the given formatter. Read more
Source§

impl ParsedImplExt for ParsedImpl

Source§

fn constructor_context(&self) -> Option<MethodContext<'_>>

Create a MethodContext for the constructor method, if one exists.
Source§

fn instance_method_contexts(&self) -> impl Iterator<Item = MethodContext<'_>>

Iterate over all instance methods (public + private + active) as MethodContext.
Source§

fn static_method_contexts(&self) -> impl Iterator<Item = MethodContext<'_>>

Iterate over static (non-receiver) methods as MethodContext.
Source§

fn public_instance_method_contexts( &self, ) -> impl Iterator<Item = MethodContext<'_>>

Iterate over public instance methods as MethodContext (for R6 public list).
Source§

fn private_instance_method_contexts( &self, ) -> impl Iterator<Item = MethodContext<'_>>

Iterate over private instance methods as MethodContext (for R6 private list).
Source§

fn active_instance_method_contexts( &self, ) -> impl Iterator<Item = MethodContext<'_>>

Iterate over active binding methods as MethodContext (for R6 active list).

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