pub enum ReturnHandling {
Show 15 variants
Unit,
RawSexp,
ExternalPtr,
IntoR,
OptionUnit,
OptionSexp,
OptionIntoR,
OptionIntoRUnwrap,
ResultUnit,
ResultSexp,
ResultIntoR,
ResultNullOnErr,
AsListOf,
AsExternalPtrOf,
AsNativeOf,
}Expand description
Strategy for converting a Rust return value into an R SEXP.
Determined automatically by detect_return_handling from the function’s return type,
or set explicitly via CWrapperContextBuilder::return_handling. Each variant
handles a different return type pattern, controlling how the C wrapper converts
the Rust value back to R and how errors/None values are surfaced.
Variants§
Unit
Returns unit type () – emits R_NilValue.
RawSexp
Returns raw SEXP – passes the value through unchanged (no conversion).
ExternalPtr
Returns Self – wraps the value in an ExternalPtr via ExternalPtr::new.
IntoR
Returns an arbitrary type T: IntoR – converts via IntoR::into_sexp.
OptionUnit
Returns Option<()> – raises an error on None, otherwise emits R_NilValue.
OptionSexp
Returns Option<SEXP> – raises an error on None, otherwise passes through.
OptionIntoR
Returns Option<T> where Option<T>: IntoR – calls IntoR::into_sexp on the whole
Option value. Suitable when the type has a direct impl IntoR for Option<T> (e.g.,
Option<&T>, Option<Vec<T>>, Option<i32>). None maps to whatever the IntoR
impl returns (typically NULL or NA).
Use this variant explicitly via CWrapperContextBuilder::return_handling when
the type has a direct IntoR impl for the whole Option. The auto-detector
detect_return_handling conservatively returns [OptionIntoRUnwrap] instead
since it cannot resolve trait impls at macro expansion time.
OptionIntoRUnwrap
Returns Option<T> where T: IntoR – unwraps the option first, then converts the
inner value via IntoR::into_sexp. Raises an error on None. Suitable when T: IntoR
but Option<T> doesn’t have a direct IntoR impl (e.g., Option<SomeExternalPtr>).
ResultUnit
Returns Result<(), E> – raises an error on Err, otherwise emits R_NilValue.
ResultSexp
Returns Result<SEXP, E> – raises an error on Err, otherwise passes through.
ResultIntoR
Returns Result<T, E> – raises an error on Err, otherwise converts via IntoR::into_sexp.
ResultNullOnErr
Returns Result<T, ()> – maps Err(()) to Err(NullOnErr) then converts via IntoR.
None/Err maps to R NULL (unit error is a deliberate sentinel, not a Rust failure).
AsListOf
Returns T where T: IntoList – wraps in AsList(result) then calls IntoR::into_sexp.
Produced when #[miniextendr(prefer = "list")] is used on a function returning T: IntoList.
Distinct from returning AsList<T> explicitly only in that the wrapping is generated
by the macro rather than written by the user.
AsExternalPtrOf
Returns T where T: IntoExternalPtr – wraps in AsExternalPtr(result) then calls IntoR::into_sexp.
Produced when #[miniextendr(prefer = "externalptr")] is used on a function returning
T: IntoExternalPtr. Distinct from the existing ExternalPtr variant (which boxes Self
via ExternalPtr::new): this variant calls IntoExternalPtr::into_external_ptr() on T.
AsNativeOf
Returns T where T: RNativeType – wraps in AsRNative(result) then calls IntoR::into_sexp.
Produced when #[miniextendr(prefer = "native")] is used on a function returning T: RNativeType.
Trait Implementations§
Source§impl Clone for ReturnHandling
impl Clone for ReturnHandling
Source§fn clone(&self) -> ReturnHandling
fn clone(&self) -> ReturnHandling
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ReturnHandling
impl RefUnwindSafe for ReturnHandling
impl Send for ReturnHandling
impl Sync for ReturnHandling
impl Unpin for ReturnHandling
impl UnsafeUnpin for ReturnHandling
impl UnwindSafe for ReturnHandling
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> 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: 1 byte
Size for each variant:
Unit: 0 bytesRawSexp: 0 bytesExternalPtr: 0 bytesIntoR: 0 bytesOptionUnit: 0 bytesOptionSexp: 0 bytesOptionIntoR: 0 bytesOptionIntoRUnwrap: 0 bytesResultUnit: 0 bytesResultSexp: 0 bytesResultIntoR: 0 bytesResultNullOnErr: 0 bytesAsListOf: 0 bytesAsExternalPtrOf: 0 bytesAsNativeOf: 0 bytes