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 named target must have a compatible R class definition. Explicit wrapping does not consult the class registry or verify the selected system; a mismatch is reported by R when the generated constructor or method is used.

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.