Skip to main content

Module wrap_as

Module wrap_as 

Source
Expand description

Explicit R class-system return markers. Explicit R class-system return markers.

WrapAsR6<T> and its siblings select the constructor used by the generated R wrapper. The matching attribute is #[miniextendr(wrap = "r6")]. Both forms leave Rust-to-R value conversion to T; they only select the R-side wrapping expression. See docs/MINIEXTENDR_ATTRIBUTE.md for examples.

ConvertTo<T> and ConvertFrom<T> additionally register an inherent S7 method with S7::convert. ConvertTo<T> names the target payload; ConvertFrom<Self> infers the source from its static method’s sole typed parameter. Both use the existing S7 class-name resolver, including registered R class renames, and have matching s7(convert_to = "Target") / s7(convert_from = "Source") attributes.

Markers are recognized by their last path segment. Type aliases and renamed imports do not select wrapping. Put Invisible/Visible outside the whole return, and Option, Result, or Vec outside the class marker.

The marker selects the class system; the class name is the R name the target’s #[miniextendr] impl block registers, resolved when the R wrappers are written, so a class = "..." rename applies (Self is the implementing class). A target with no impl block keeps its Rust name: quietly for S3, Env and vctrs, where any string is a class, and with a warning for R6, S7 and S4, whose class object must exist. Nothing checks that the selected system matches the class definition; a mismatch is reported by R when the generated constructor or method is used.

Re-exports§

use crate::IntoR; 🔒
use crate::IntoR; 🔒

Macros§

wrap_marker 🔒

Structs§

ConvertFrom
Return the enclosing S7 class from a static conversion method. Its sole typed source parameter determines the s7(convert_from = "Source") registration.
ConvertTo
Return an S7 target class and register the inherent method with S7::convert. The equivalent attribute is s7(convert_to = "Target").
WrapAsEnv
Return T with its Env dispatch class.
WrapAsR6
Return T through its R6 constructor (T$new(.ptr = value)).
WrapAsS3
Return T with its named S3 class.
WrapAsS4
Return T through methods::new("T", ptr = value).
WrapAsS7
Return T through its S7 constructor (T(.ptr = value)).
WrapAsVctrs
Return T with its named vctrs class, preserving its existing class hierarchy.