Skip to main content

ReturnHandling

Enum ReturnHandling 

Source
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

Source§

fn clone(&self) -> ReturnHandling

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ReturnHandling

Source§

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

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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: 1 byte

Size for each variant:

  • Unit: 0 bytes
  • RawSexp: 0 bytes
  • ExternalPtr: 0 bytes
  • IntoR: 0 bytes
  • OptionUnit: 0 bytes
  • OptionSexp: 0 bytes
  • OptionIntoR: 0 bytes
  • OptionIntoRUnwrap: 0 bytes
  • ResultUnit: 0 bytes
  • ResultSexp: 0 bytes
  • ResultIntoR: 0 bytes
  • ResultNullOnErr: 0 bytes
  • AsListOf: 0 bytes
  • AsExternalPtrOf: 0 bytes
  • AsNativeOf: 0 bytes