Skip to main content

TryFromSexp

Trait TryFromSexp 

Source
pub trait TryFromSexp: Sized {
    type Error;

    // Required method
    fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>;

    // Provided method
    unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error> { ... }
}
Expand description

TryFrom-style trait for converting SEXP to Rust types.

§Examples

use miniextendr_api::ffi::SEXP;
use miniextendr_api::from_r::TryFromSexp;

fn example(sexp: SEXP) {
    let value: i32 = TryFromSexp::try_from_sexp(sexp).unwrap();
    let text: String = TryFromSexp::try_from_sexp(sexp).unwrap();
}

Required Associated Types§

Source

type Error

The error type returned when conversion fails.

Required Methods§

Source

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Attempt to convert an R SEXP to this Rust type.

In debug builds, may assert that we’re on R’s main thread.

Provided Methods§

Source

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Convert from SEXP without thread safety checks.

§Safety

Must be called from R’s main thread. In debug builds, this still calls the checked version by default, but implementations may skip thread assertions for performance.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl TryFromSexp for &'static f64

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for &'static i32

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for &'static str

Convert R character vector (STRSXP) to Rust &str.

Extracts the first element of the character vector and returns it as a UTF-8 string. The returned string has static lifetime because it points to R’s internal string pool.

§NA Handling

Warning: NA_character_ is converted to empty string "". This is lossy! If you need to distinguish between NA and empty strings, use Option<String> instead:

let maybe_str: Option<String> = sexp.try_into()?;

§Safety

The returned &str is only valid as long as R doesn’t garbage collect the CHARSXP. In practice, this is safe within a single .Call invocation.

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for &'static u8

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for &'static mut f64

§Safety note (aliasing)

This impl can produce aliased &mut references if the same R object is passed to multiple mutable parameters. The caller (generated wrapper) is responsible for ensuring no two &mut borrows alias the same SEXP.

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for &'static mut i32

§Safety note (aliasing)

This impl can produce aliased &mut references if the same R object is passed to multiple mutable parameters. The caller (generated wrapper) is responsible for ensuring no two &mut borrows alias the same SEXP.

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for &'static mut u8

§Safety note (aliasing)

This impl can produce aliased &mut references if the same R object is passed to multiple mutable parameters. The caller (generated wrapper) is responsible for ensuring no two &mut borrows alias the same SEXP.

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Cow<'static, str>

Convert R character scalar to Cow<'static, str>.

Returns Cow::Borrowed — the &str points directly into R’s CHARSXP data via R_CHAR + LENGTH (O(1), no strlen). No allocation or copy occurs. The 'static lifetime is valid for the duration of the .Call invocation.

This delegates to the &'static str impl (which uses charsxp_to_str), giving the same zero-copy behavior. Use Cow when your code may need to mutate the string later — to_mut() will copy-on-write at that point.

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<&'static f64>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<&'static i32>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<&'static str>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<&'static u8>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<&'static RLogical>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<&'static Rcomplex>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<&'static mut f64>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<&'static mut i32>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<&'static mut u8>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<&'static mut RLogical>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<&'static mut Rcomplex>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<Rboolean>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<bool>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<f32>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<f64>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<i8>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<i16>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<i32>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<i64>

Convert R numeric scalar to Option<i64>, with NA → None.

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<isize>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<u8>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<u16>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<u32>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<u64>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<usize>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<RLogical>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<Rcomplex>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<SEXP>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<List>

Source§

impl TryFromSexp for Option<ListMut>

Source§

impl TryFromSexp for Option<NamedList>

Source§

impl TryFromSexp for Option<String>

NA-aware string conversion: returns None for NA_character_.

Use this when you need to distinguish between NA and empty strings:

let maybe_str: Option<String> = sexp.try_into()?;
match maybe_str {
    Some(s) => println!("Got string: {}", s),
    None => println!("Got NA"),
}
Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<OsString>

NA-aware OsString conversion: returns None for NA_character_ or NULL.

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Option<PathBuf>

NA-aware PathBuf conversion: returns None for NA_character_ or NULL.

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for bool

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for char

Convert R character vector (STRSXP) to Rust char.

Extracts the first character of the first element of the character vector. Returns an error if the string is empty, NA, or has more than one character.

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for f32

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for f64

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for i8

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for i16

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for i32

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for i64

Convert R numeric scalar to i64.

§Behavior

  • Reads from REALSXP (f64) or INTSXP (i32)
  • Validates value is a whole number (no fractional part)
  • Validates value fits in i64 range
  • Returns Err for NA values

§Example

// From R integer
let val: i64 = TryFromSexp::try_from_sexp(int_sexp)?;

// From R numeric (must be whole number)
let val: i64 = TryFromSexp::try_from_sexp(real_sexp)?;

// Error: 3.14 is not a whole number
let val: Result<i64, _> = TryFromSexp::try_from_sexp(pi_sexp);
Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for isize

Source§

impl TryFromSexp for u8

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for u16

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for u32

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for u64

Convert R numeric scalar to u64.

Same behavior as i64(impl TryFromSexp for i64), but also validates the value is non-negative.

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for usize

Source§

impl TryFromSexp for Box<[Cow<'static, str>]>

Convert R character vector to Box<[Cow<'static, str>]> — zero-copy per element.

Warning: NA_character_ values are converted to Cow::Borrowed("").

Source§

impl TryFromSexp for Box<[Option<bool>]>

Convert R logical vector (LGLSXP) to Box<[Option<bool>]> with NA support.

Source§

impl TryFromSexp for Box<[Option<f64>]>

Source§

impl TryFromSexp for Box<[Option<i32>]>

Source§

impl TryFromSexp for Box<[Option<String>]>

Convert R character vector to Box<[Option<String>]> with NA support.

Source§

impl TryFromSexp for Box<[bool]>

Source§

impl TryFromSexp for Box<[f64]>

Source§

impl TryFromSexp for Box<[i32]>

Source§

impl TryFromSexp for Box<[u8]>

Source§

impl TryFromSexp for Box<[RLogical]>

Source§

impl TryFromSexp for Box<[Rcomplex]>

Source§

impl TryFromSexp for Box<[String]>

Convert R character vector to Box<[String]>.

Warning: NA_character_ values are converted to empty string "".

Source§

impl TryFromSexp for BTreeSet<bool>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for BTreeSet<i8>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for BTreeSet<i16>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for BTreeSet<i32>

Source§

impl TryFromSexp for BTreeSet<i64>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for BTreeSet<isize>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for BTreeSet<u8>

Source§

impl TryFromSexp for BTreeSet<u16>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for BTreeSet<u32>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for BTreeSet<u64>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for BTreeSet<usize>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for BTreeSet<String>

Convert R character vector to BTreeSet<String>.

Source§

impl TryFromSexp for String

Convert R character vector (STRSXP) to owned Rust String.

Extracts the first element and creates an owned copy.

§NA Handling

Warning: NA_character_ is converted to empty string "". This is lossy! If you need to distinguish between NA and empty strings, use Option<String> instead:

let maybe_str: Option<String> = sexp.try_into()?;
Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<&'static f64>

Source§

impl TryFromSexp for Vec<&'static i32>

Source§

impl TryFromSexp for Vec<&'static str>

Convert R character vector to Vec<&str>.

Warning: NA_character_ values are converted to empty string "".

Source§

impl TryFromSexp for Vec<&'static u8>

Source§

impl TryFromSexp for Vec<&'static RLogical>

Source§

impl TryFromSexp for Vec<&'static Rcomplex>

Source§

impl TryFromSexp for Vec<&'static [f64]>

Source§

impl TryFromSexp for Vec<&'static [i32]>

Source§

impl TryFromSexp for Vec<&'static [u8]>

Source§

impl TryFromSexp for Vec<&'static [RLogical]>

Source§

impl TryFromSexp for Vec<&'static [Rcomplex]>

Source§

impl TryFromSexp for Vec<&'static mut f64>

Source§

impl TryFromSexp for Vec<&'static mut i32>

Source§

impl TryFromSexp for Vec<&'static mut u8>

Source§

impl TryFromSexp for Vec<&'static mut RLogical>

Source§

impl TryFromSexp for Vec<&'static mut Rcomplex>

Source§

impl TryFromSexp for Vec<&'static mut [f64]>

Source§

impl TryFromSexp for Vec<&'static mut [i32]>

Source§

impl TryFromSexp for Vec<&'static mut [u8]>

Source§

impl TryFromSexp for Vec<&'static mut [RLogical]>

Source§

impl TryFromSexp for Vec<&'static mut [Rcomplex]>

Source§

impl TryFromSexp for Vec<Logical>

Convert R logical vector (LGLSXP) to Vec<Logical> (ALTREP-compatible).

This converts R’s logical vector to a vector of Logical values, which is the native representation used by ALTREP logical vectors. Unlike Vec<bool>, this preserves NA values.

Source§

impl TryFromSexp for Vec<Rboolean>

Convert R logical vector (LGLSXP) to Vec<Rboolean> (errors on NA).

Source§

impl TryFromSexp for Vec<Cow<'static, str>>

Convert R character vector to Vec<Cow<'static, str>> — zero-copy per element.

Each element borrows directly from R’s CHARSXP data when UTF-8 (the common case). Non-UTF-8 elements fall back to Rf_translateCharUTF8 (copies only those).

§NA Handling

Warning: NA_character_ is converted to Cow::Borrowed(""). This is lossy! Use Vec<Option<Cow<'static, str>>> to distinguish NA from empty strings.

Source§

impl TryFromSexp for Vec<Option<&'static f64>>

Source§

impl TryFromSexp for Vec<Option<&'static i32>>

Source§

impl TryFromSexp for Vec<Option<&'static str>>

Convert R character vector to Vec<Option<&str>>.

Source§

impl TryFromSexp for Vec<Option<&'static u8>>

Source§

impl TryFromSexp for Vec<Option<&'static RLogical>>

Source§

impl TryFromSexp for Vec<Option<&'static Rcomplex>>

Source§

impl TryFromSexp for Vec<Option<&'static [f64]>>

Source§

impl TryFromSexp for Vec<Option<&'static [i32]>>

Source§

impl TryFromSexp for Vec<Option<&'static [u8]>>

Source§

impl TryFromSexp for Vec<Option<&'static [RLogical]>>

Source§

impl TryFromSexp for Vec<Option<&'static [Rcomplex]>>

Source§

impl TryFromSexp for Vec<Option<&'static mut f64>>

Source§

impl TryFromSexp for Vec<Option<&'static mut i32>>

Source§

impl TryFromSexp for Vec<Option<&'static mut u8>>

Source§

impl TryFromSexp for Vec<Option<&'static mut RLogical>>

Source§

impl TryFromSexp for Vec<Option<&'static mut Rcomplex>>

Source§

impl TryFromSexp for Vec<Option<&'static mut [f64]>>

Source§

impl TryFromSexp for Vec<Option<&'static mut [i32]>>

Source§

impl TryFromSexp for Vec<Option<&'static mut [u8]>>

Source§

impl TryFromSexp for Vec<Option<&'static mut [RLogical]>>

Source§

impl TryFromSexp for Vec<Option<&'static mut [Rcomplex]>>

Source§

impl TryFromSexp for Vec<Option<Rboolean>>

Convert R logical vector (LGLSXP) to Vec<Option<Rboolean>> with NA support.

Source§

impl TryFromSexp for Vec<Option<Cow<'static, str>>>

Convert R character vector to Vec<Option<Cow<'static, str>>> — zero-copy, NA-aware.

NA_character_None, valid strings → Some(Cow::Borrowed(&str)).

Source§

impl TryFromSexp for Vec<Option<bool>>

Convert R logical vector (LGLSXP) to Vec<Option<bool>> with NA support.

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<Option<f32>>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<Option<f64>>

Source§

impl TryFromSexp for Vec<Option<i8>>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<Option<i16>>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<Option<i32>>

Source§

impl TryFromSexp for Vec<Option<i64>>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<Option<isize>>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<Option<u8>>

Convert R raw vector (RAWSXP) to Vec<Option<u8>>.

Source§

impl TryFromSexp for Vec<Option<u16>>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<Option<u32>>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<Option<u64>>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<Option<usize>>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<Option<RLogical>>

Convert R logical vector (LGLSXP) to Vec<Option<RLogical>> with NA support.

Source§

impl TryFromSexp for Vec<Option<String>>

Convert R character vector (STRSXP) to Vec<Option<String>> with NA support.

NA_character_ elements are converted to None.

Source§

impl TryFromSexp for Vec<Option<OsString>>

Convert R character vector (STRSXP) to Vec<Option<OsString>> with NA support.

NA_character_ elements are converted to None.

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<Option<PathBuf>>

Convert R character vector (STRSXP) to Vec<Option<PathBuf>> with NA support.

NA_character_ elements are converted to None.

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<bool>

Convert R logical vector (LGLSXP) to Vec<bool> (errors on NA).

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<f32>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<f64>

Source§

impl TryFromSexp for Vec<i8>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<i16>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<i32>

Source§

impl TryFromSexp for Vec<i64>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<isize>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<u8>

Source§

impl TryFromSexp for Vec<u16>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<u32>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<u64>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<usize>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<RLogical>

Source§

impl TryFromSexp for Vec<Rcomplex>

Source§

impl TryFromSexp for Vec<String>

Convert R character vector to Vec<String>.

§NA and Encoding Handling

Warning: This conversion is lossy for NA values and encoding failures:

  • NA_character_ values are converted to empty string ""
  • Encoding translation failures become empty string ""
  • Invalid UTF-8 (after translation) becomes empty string ""

If you need to preserve NA semantics, use Vec<Option<String>> instead:

let strings: Vec<Option<String>> = sexp.try_into()?;
// NA values will be None, valid strings will be Some(s)

This design choice prioritizes convenience over strict correctness for the common case where strings are known to be non-NA and properly encoded.

Source§

impl TryFromSexp for Vec<OsString>

Convert R character vector (STRSXP) to Vec<OsString>.

§NA Handling

Warning: NA_character_ elements are converted to empty strings. Use Vec<Option<OsString>> if you need to preserve NA values.

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for Vec<PathBuf>

Convert R character vector (STRSXP) to Vec<PathBuf>.

§NA Handling

Warning: NA_character_ elements are converted to empty paths. Use Vec<Option<PathBuf>> if you need to preserve NA values.

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for HashSet<bool>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for HashSet<i8>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for HashSet<i16>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for HashSet<i32>

Source§

impl TryFromSexp for HashSet<i64>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for HashSet<isize>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for HashSet<u8>

Source§

impl TryFromSexp for HashSet<u16>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for HashSet<u32>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for HashSet<u64>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for HashSet<usize>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for HashSet<RLogical>

Source§

impl TryFromSexp for HashSet<String>

Convert R character vector to HashSet<String>.

Source§

impl TryFromSexp for OsString

Convert R character scalar (STRSXP of length 1) to OsString.

Since R strings are converted to UTF-8, the resulting OsString contains valid UTF-8 data.

§NA Handling

Warning: NA_character_ is converted to empty string. This is lossy! If you need to distinguish between NA and empty strings, use Option<OsString> instead.

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl TryFromSexp for PathBuf

Convert R character scalar (STRSXP of length 1) to PathBuf.

§NA Handling

Warning: NA_character_ is converted to empty path "". This is lossy! If you need to distinguish between NA and empty strings, use Option<PathBuf> instead.

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl<T> TryFromSexp for &[T]
where T: RNativeType + Copy,

Blanket impl for &[T] where T: RNativeType

This replaces the macro-generated &'static [T] impls with a more composable blanket impl that works for any lifetime. This enables containers like TinyVec to use blanket impls without needing helper functions.

Source§

type Error = SexpTypeError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl<T> TryFromSexp for &mut [T]
where T: RNativeType + Copy,

Blanket impl for &mut [T] where T: RNativeType

§Safety note (aliasing)

This impl can produce aliased &mut slices if the same R vector is passed to multiple mutable slice parameters. The caller is responsible for ensuring no two &mut borrows alias the same SEXP.

Source§

type Error = SexpTypeError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl<T> TryFromSexp for Cow<'static, [T]>
where T: RNativeType + Copy + Clone,

Blanket impl: Convert R vector to Cow<'static, [T]> where T: RNativeType.

Returns Cow::Borrowed — the slice points directly into R’s SEXP data with no copy. The 'static lifetime is valid for the duration of the .Call invocation (R protects the SEXP from GC while Rust code is running).

Important: Do not send the borrowed Cow to another thread or store it past the .Call return — the underlying R memory is only valid while R’s protection stack guards this SEXP.

Source§

type Error = SexpTypeError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl<T> TryFromSexp for Option<&[T]>
where T: RNativeType + Copy,

Blanket impl for Option<&[T]> where T: RNativeType

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl<T> TryFromSexp for Option<&mut [T]>
where T: RNativeType + Copy,

Blanket impl for Option<&mut [T]> where T: RNativeType

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl<T> TryFromSexp for Option<BTreeSet<T>>

Convert R value to Option<BTreeSet<T>>: NULL -> None, otherwise Some(set).

Source§

impl<T> TryFromSexp for Option<Vec<T>>

Convert R value to Option<Vec<T>>: NULL → None, otherwise Some(vec).

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl<T> TryFromSexp for Option<HashSet<T>>

Convert R value to Option<HashSet<T>>: NULL -> None, otherwise Some(set).

Source§

impl<T> TryFromSexp for Result<T, ()>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl<T> TryFromSexp for BinaryHeap<T>
where T: RNativeType + Copy + Ord,

Blanket impl: Convert R vector to BinaryHeap<T> where T: RNativeType + Ord.

Creates a binary heap from the R vector elements.

Source§

type Error = SexpTypeError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl<T> TryFromSexp for VecDeque<T>
where T: RNativeType + Copy,

Blanket impl: Convert R vector to VecDeque<T> where T: RNativeType.

Source§

type Error = SexpTypeError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl<T> TryFromSexp for Vec<Vec<T>>

Convert R list (VECSXP) to Vec<Vec<T>>.

Each element of the R list must be convertible to Vec<T>.

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl<T, const N: usize> TryFromSexp for [T; N]
where T: RNativeType + Copy,

Blanket impl: Convert R vector to [T; N] where T: RNativeType.

Returns an error if the R vector length doesn’t match N. Useful for SHA hashes ([u8; 32]), fixed-size patterns, etc.

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl<T: TypedExternal + Send> TryFromSexp for Option<ExternalPtr<T>>

Source§

type Error = SexpError

Source§

fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>

Source§

unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>

Source§

impl<V: TryFromSexp> TryFromSexp for Option<BTreeMap<String, V>>
where V::Error: Into<SexpError>,

Convert R value to Option<BTreeMap<String, V>>: NULL -> None, otherwise Some(map).

Source§

impl<V: TryFromSexp> TryFromSexp for Option<HashMap<String, V>>
where V::Error: Into<SexpError>,

Convert R value to Option<HashMap<String, V>>: NULL -> None, otherwise Some(map).

Source§

impl<V: TryFromSexp> TryFromSexp for BTreeMap<String, V>
where V::Error: Into<SexpError>,

Convert R named list (VECSXP) to BTreeMap<String, V>.

See named_list_to_map for NA/empty name handling (elements with NA/empty names map to key "" and may silently overwrite each other).

Source§

impl<V: TryFromSexp> TryFromSexp for Vec<BTreeMap<String, V>>
where V::Error: Into<SexpError>,

Convert R list of named lists to Vec<BTreeMap<String, V>>.

Source§

impl<V: TryFromSexp> TryFromSexp for Vec<HashMap<String, V>>
where V::Error: Into<SexpError>,

Convert R list of named lists to Vec<HashMap<String, V>>.

Source§

impl<V: TryFromSexp> TryFromSexp for HashMap<String, V>
where V::Error: Into<SexpError>,

Convert R named list (VECSXP) to HashMap<String, V>.

See named_list_to_map for NA/empty name handling (elements with NA/empty names map to key "" and may silently overwrite each other).

Implementors§

Source§

impl TryFromSexp for &'static RLogical

Source§

impl TryFromSexp for &'static Rcomplex

Source§

impl TryFromSexp for &'static mut RLogical

§Safety note (aliasing)

This impl can produce aliased &mut references if the same R object is passed to multiple mutable parameters. The caller (generated wrapper) is responsible for ensuring no two &mut borrows alias the same SEXP.

Source§

impl TryFromSexp for &'static mut Rcomplex

§Safety note (aliasing)

This impl can produce aliased &mut references if the same R object is passed to multiple mutable parameters. The caller (generated wrapper) is responsible for ensuring no two &mut borrows alias the same SEXP.

Source§

impl TryFromSexp for Rboolean

Source§

impl TryFromSexp for AltrepSexp

Conversion from R SEXP to AltrepSexp.

Only succeeds if the input is an ALTREP vector (ALTREP(sexp) != 0). Non-ALTREP input produces SexpError::InvalidValue.

This is the inverse of TryFromSexp for SEXP, which accepts any SEXP but auto-materializes ALTREP.

Source§

impl TryFromSexp for DataFrameView

Source§

impl TryFromSexp for RLogical

Source§

impl TryFromSexp for Rcomplex

Source§

impl TryFromSexp for SEXP

Pass-through conversion for raw SEXP values with ALTREP auto-materialization.

This allows SEXP to be used directly in #[miniextendr] function signatures. When R passes an ALTREP vector (e.g., 1:10, seq_len(N)), ensure_materialized is called automatically to force materialization on the R main thread. After this, the SEXP’s data pointer is stable and safe to access from any thread.

§ALTREP handling

InputResult
Regular SEXPPassed through unchanged
ALTREP SEXPMaterialized via ensure_materialized, then passed through

To receive ALTREP without materializing, use AltrepSexp as the parameter type instead. To receive the raw SEXP without any conversion (including no materialization), use extern "C-unwind".

See docs/ALTREP_SEXP.md for the full guide.

§Safety

SEXP handles are only valid on R’s main thread. Use with #[miniextendr(unsafe(main_thread))] functions.

Source§

impl TryFromSexp for List

Source§

impl TryFromSexp for ListMut

Source§

impl TryFromSexp for NamedList

Source§

impl TryFromSexp for ProtectedStrVec

Source§

impl TryFromSexp for StrVec

Source§

impl<'a> TryFromSexp for Factor<'a>

Source§

impl<T> TryFromSexp for Missing<T>

Source§

impl<T, R> TryFromSexp for Coerced<T, R>
where R: TryFromSexp + TryCoerce<T>, <R as TryFromSexp>::Error: Into<SexpError>, <R as TryCoerce<T>>::Error: Debug,

Convert R value to Coerced<T, R> by reading R and coercing to T.

This enables reading non-native Rust types from R with coercion:

// Read i64 from R integer (i32)
let val: Coerced<i64, i32> = TryFromSexp::try_from_sexp(sexp)?;
let i64_val: i64 = val.into_inner();

// Works with collections too:
let vec: Vec<Coerced<i64, i32>> = ...;
let set: HashSet<Coerced<NonZeroU32, i32>> = ...;
Source§

impl<T: TypedExternal + Send> TryFromSexp for ExternalPtr<T>

Convert R EXTPTRSXP to ExternalPtr<T>.

This enables using ExternalPtr<T> as parameter types in #[miniextendr] functions.

§Example

#[derive(ExternalPtr)]
struct MyData { value: i32 }

#[miniextendr]
fn process(data: ExternalPtr<MyData>) -> i32 {
    data.value
}
Source§

impl<T: RFactor> TryFromSexp for FactorOptionVec<T>

Source§

impl<T: RFactor> TryFromSexp for FactorVec<T>

Source§

impl<T: RNativeType, const NDIM: usize> TryFromSexp for RArray<T, NDIM>

Source§

impl<T: FromStr> TryFromSexp for AsFromStr<T>
where T::Err: Display,

Source§

impl<T: FromStr> TryFromSexp for AsFromStrVec<T>
where T::Err: Display,

Source§

impl<V: AtomicElement> TryFromSexp for NamedVector<BTreeMap<String, V>>

Source§

impl<V: AtomicElement> TryFromSexp for NamedVector<HashMap<String, V>>

Source§

impl<const NDIM: usize> TryFromSexp for RArray<bool, NDIM>

Source§

impl<const NDIM: usize> TryFromSexp for RArray<f32, NDIM>

Source§

impl<const NDIM: usize> TryFromSexp for RArray<i8, NDIM>

Source§

impl<const NDIM: usize> TryFromSexp for RArray<i16, NDIM>

Source§

impl<const NDIM: usize> TryFromSexp for RArray<i64, NDIM>

Source§

impl<const NDIM: usize> TryFromSexp for RArray<isize, NDIM>

Source§

impl<const NDIM: usize> TryFromSexp for RArray<u16, NDIM>

Source§

impl<const NDIM: usize> TryFromSexp for RArray<u32, NDIM>

Source§

impl<const NDIM: usize> TryFromSexp for RArray<u64, NDIM>

Source§

impl<const NDIM: usize> TryFromSexp for RArray<usize, NDIM>