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§
Required Methods§
Sourcefn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>
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§
Sourceunsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>
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
impl TryFromSexp for &'static f64
Source§impl TryFromSexp for &'static i32
impl TryFromSexp for &'static i32
Source§impl TryFromSexp for &'static str
Convert R character vector (STRSXP) to Rust &str.
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§impl TryFromSexp for &'static u8
impl TryFromSexp for &'static u8
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.
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§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.
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§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.
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§impl TryFromSexp for Cow<'static, str>
Convert R character scalar to Cow<'static, str>.
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§impl TryFromSexp for Option<&'static f64>
impl TryFromSexp for Option<&'static f64>
Source§impl TryFromSexp for Option<&'static i32>
impl TryFromSexp for Option<&'static i32>
Source§impl TryFromSexp for Option<&'static str>
impl TryFromSexp for Option<&'static str>
Source§impl TryFromSexp for Option<&'static u8>
impl TryFromSexp for Option<&'static u8>
Source§impl TryFromSexp for Option<&'static RLogical>
impl TryFromSexp for Option<&'static RLogical>
Source§impl TryFromSexp for Option<&'static Rcomplex>
impl TryFromSexp for Option<&'static Rcomplex>
Source§impl TryFromSexp for Option<&'static mut f64>
impl TryFromSexp for Option<&'static mut f64>
Source§impl TryFromSexp for Option<&'static mut i32>
impl TryFromSexp for Option<&'static mut i32>
Source§impl TryFromSexp for Option<&'static mut u8>
impl TryFromSexp for Option<&'static mut u8>
Source§impl TryFromSexp for Option<&'static mut RLogical>
impl TryFromSexp for Option<&'static mut RLogical>
Source§impl TryFromSexp for Option<&'static mut Rcomplex>
impl TryFromSexp for Option<&'static mut Rcomplex>
Source§impl TryFromSexp for Option<Rboolean>
impl TryFromSexp for Option<Rboolean>
Source§impl TryFromSexp for Option<bool>
impl TryFromSexp for Option<bool>
Source§impl TryFromSexp for Option<f32>
impl TryFromSexp for Option<f32>
Source§impl TryFromSexp for Option<f64>
impl TryFromSexp for Option<f64>
Source§impl TryFromSexp for Option<i8>
impl TryFromSexp for Option<i8>
Source§impl TryFromSexp for Option<i16>
impl TryFromSexp for Option<i16>
Source§impl TryFromSexp for Option<i32>
impl TryFromSexp for Option<i32>
Source§impl TryFromSexp for Option<i64>
Convert R numeric scalar to Option<i64>, with NA → None.
impl TryFromSexp for Option<i64>
Convert R numeric scalar to Option<i64>, with NA → None.
Source§impl TryFromSexp for Option<isize>
impl TryFromSexp for Option<isize>
Source§impl TryFromSexp for Option<u8>
impl TryFromSexp for Option<u8>
Source§impl TryFromSexp for Option<u16>
impl TryFromSexp for Option<u16>
Source§impl TryFromSexp for Option<u32>
impl TryFromSexp for Option<u32>
Source§impl TryFromSexp for Option<u64>
impl TryFromSexp for Option<u64>
Source§impl TryFromSexp for Option<usize>
impl TryFromSexp for Option<usize>
Source§impl TryFromSexp for Option<RLogical>
impl TryFromSexp for Option<RLogical>
Source§impl TryFromSexp for Option<Rcomplex>
impl TryFromSexp for Option<Rcomplex>
Source§impl TryFromSexp for Option<SEXP>
impl TryFromSexp for Option<SEXP>
Source§impl TryFromSexp for Option<List>
impl TryFromSexp for Option<List>
Source§impl TryFromSexp for Option<ListMut>
impl TryFromSexp for Option<ListMut>
Source§impl TryFromSexp for Option<NamedList>
impl TryFromSexp for Option<NamedList>
Source§impl TryFromSexp for Option<String>
NA-aware string conversion: returns None for NA_character_.
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§impl TryFromSexp for Option<OsString>
NA-aware OsString conversion: returns None for NA_character_ or NULL.
impl TryFromSexp for Option<OsString>
NA-aware OsString conversion: returns None for NA_character_ or NULL.
Source§impl TryFromSexp for Option<PathBuf>
NA-aware PathBuf conversion: returns None for NA_character_ or NULL.
impl TryFromSexp for Option<PathBuf>
NA-aware PathBuf conversion: returns None for NA_character_ or NULL.
Source§impl TryFromSexp for bool
impl TryFromSexp for bool
Source§impl TryFromSexp for char
Convert R character vector (STRSXP) to Rust char.
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§impl TryFromSexp for f32
impl TryFromSexp for f32
Source§impl TryFromSexp for f64
impl TryFromSexp for f64
Source§impl TryFromSexp for i8
impl TryFromSexp for i8
Source§impl TryFromSexp for i16
impl TryFromSexp for i16
Source§impl TryFromSexp for i32
impl TryFromSexp for i32
Source§impl TryFromSexp for i64
Convert R numeric scalar to i64.
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
Errfor 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§impl TryFromSexp for isize
impl TryFromSexp for isize
Source§impl TryFromSexp for u8
impl TryFromSexp for u8
Source§impl TryFromSexp for u16
impl TryFromSexp for u16
Source§impl TryFromSexp for u32
impl TryFromSexp for u32
Source§impl TryFromSexp for u64
Convert R numeric scalar to u64.
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§impl TryFromSexp for usize
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.
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.
impl TryFromSexp for Box<[Option<bool>]>
Convert R logical vector (LGLSXP) to Box<[Option<bool>]> with NA support.
Source§impl TryFromSexp for Box<[Option<String>]>
Convert R character vector to Box<[Option<String>]> with NA support.
impl TryFromSexp for Box<[Option<String>]>
Convert R character vector to Box<[Option<String>]> with NA support.
Source§impl TryFromSexp for Box<[bool]>
impl TryFromSexp for Box<[bool]>
Source§impl TryFromSexp for Box<[f64]>
impl TryFromSexp for Box<[f64]>
type Error = SexpTypeError
fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>
Source§impl TryFromSexp for Box<[i32]>
impl TryFromSexp for Box<[i32]>
type Error = SexpTypeError
fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>
Source§impl TryFromSexp for Box<[u8]>
impl TryFromSexp for Box<[u8]>
type Error = SexpTypeError
fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>
Source§impl TryFromSexp for Box<[RLogical]>
impl TryFromSexp for Box<[RLogical]>
type Error = SexpTypeError
fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>
Source§impl TryFromSexp for Box<[Rcomplex]>
impl TryFromSexp for Box<[Rcomplex]>
type Error = SexpTypeError
fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>
Source§impl TryFromSexp for Box<[String]>
Convert R character vector to Box<[String]>.
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>
impl TryFromSexp for BTreeSet<bool>
Source§impl TryFromSexp for BTreeSet<i8>
impl TryFromSexp for BTreeSet<i8>
Source§impl TryFromSexp for BTreeSet<i16>
impl TryFromSexp for BTreeSet<i16>
Source§impl TryFromSexp for BTreeSet<i32>
impl TryFromSexp for BTreeSet<i32>
type Error = SexpTypeError
fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>
Source§impl TryFromSexp for BTreeSet<i64>
impl TryFromSexp for BTreeSet<i64>
Source§impl TryFromSexp for BTreeSet<isize>
impl TryFromSexp for BTreeSet<isize>
Source§impl TryFromSexp for BTreeSet<u8>
impl TryFromSexp for BTreeSet<u8>
type Error = SexpTypeError
fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>
Source§impl TryFromSexp for BTreeSet<u16>
impl TryFromSexp for BTreeSet<u16>
Source§impl TryFromSexp for BTreeSet<u32>
impl TryFromSexp for BTreeSet<u32>
Source§impl TryFromSexp for BTreeSet<u64>
impl TryFromSexp for BTreeSet<u64>
Source§impl TryFromSexp for BTreeSet<usize>
impl TryFromSexp for BTreeSet<usize>
Source§impl TryFromSexp for BTreeSet<String>
Convert R character vector to BTreeSet<String>.
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.
impl TryFromSexp for String
Convert R character vector (STRSXP) to owned Rust String.
Source§impl TryFromSexp for Vec<&'static f64>
impl TryFromSexp for Vec<&'static f64>
Source§impl TryFromSexp for Vec<&'static i32>
impl TryFromSexp for Vec<&'static i32>
Source§impl TryFromSexp for Vec<&'static str>
Convert R character vector to Vec<&str>.
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>
impl TryFromSexp for Vec<&'static u8>
Source§impl TryFromSexp for Vec<&'static RLogical>
impl TryFromSexp for Vec<&'static RLogical>
Source§impl TryFromSexp for Vec<&'static Rcomplex>
impl TryFromSexp for Vec<&'static Rcomplex>
Source§impl TryFromSexp for Vec<&'static [f64]>
impl TryFromSexp for Vec<&'static [f64]>
Source§impl TryFromSexp for Vec<&'static [i32]>
impl TryFromSexp for Vec<&'static [i32]>
Source§impl TryFromSexp for Vec<&'static [u8]>
impl TryFromSexp for Vec<&'static [u8]>
Source§impl TryFromSexp for Vec<&'static [RLogical]>
impl TryFromSexp for Vec<&'static [RLogical]>
Source§impl TryFromSexp for Vec<&'static [Rcomplex]>
impl TryFromSexp for Vec<&'static [Rcomplex]>
Source§impl TryFromSexp for Vec<&'static mut f64>
impl TryFromSexp for Vec<&'static mut f64>
Source§impl TryFromSexp for Vec<&'static mut i32>
impl TryFromSexp for Vec<&'static mut i32>
Source§impl TryFromSexp for Vec<&'static mut u8>
impl TryFromSexp for Vec<&'static mut u8>
Source§impl TryFromSexp for Vec<&'static mut RLogical>
impl TryFromSexp for Vec<&'static mut RLogical>
Source§impl TryFromSexp for Vec<&'static mut Rcomplex>
impl TryFromSexp for Vec<&'static mut Rcomplex>
Source§impl TryFromSexp for Vec<&'static mut [f64]>
impl TryFromSexp for Vec<&'static mut [f64]>
Source§impl TryFromSexp for Vec<&'static mut [i32]>
impl TryFromSexp for Vec<&'static mut [i32]>
Source§impl TryFromSexp for Vec<&'static mut [u8]>
impl TryFromSexp for Vec<&'static mut [u8]>
Source§impl TryFromSexp for Vec<&'static mut [RLogical]>
impl TryFromSexp for Vec<&'static mut [RLogical]>
Source§impl TryFromSexp for Vec<&'static mut [Rcomplex]>
impl TryFromSexp for Vec<&'static mut [Rcomplex]>
Source§impl TryFromSexp for Vec<Logical>
Convert R logical vector (LGLSXP) to Vec<Logical> (ALTREP-compatible).
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).
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.
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 str>>
Convert R character vector to Vec<Option<&str>>.
impl TryFromSexp for Vec<Option<&'static str>>
Convert R character vector to Vec<Option<&str>>.
Source§impl TryFromSexp for Vec<Option<Rboolean>>
Convert R logical vector (LGLSXP) to Vec<Option<Rboolean>> with NA support.
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.
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.
impl TryFromSexp for Vec<Option<bool>>
Convert R logical vector (LGLSXP) to Vec<Option<bool>> with NA support.
Source§impl TryFromSexp for Vec<Option<RLogical>>
Convert R logical vector (LGLSXP) to Vec<Option<RLogical>> with NA support.
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.
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.
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§impl TryFromSexp for Vec<Option<PathBuf>>
Convert R character vector (STRSXP) to Vec<Option<PathBuf>> with NA support.
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§impl TryFromSexp for Vec<bool>
Convert R logical vector (LGLSXP) to Vec<bool> (errors on NA).
impl TryFromSexp for Vec<bool>
Convert R logical vector (LGLSXP) to Vec<bool> (errors on NA).
Source§impl TryFromSexp for Vec<f32>
impl TryFromSexp for Vec<f32>
Source§impl TryFromSexp for Vec<f64>
impl TryFromSexp for Vec<f64>
type Error = SexpTypeError
fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>
Source§impl TryFromSexp for Vec<i8>
impl TryFromSexp for Vec<i8>
Source§impl TryFromSexp for Vec<i16>
impl TryFromSexp for Vec<i16>
Source§impl TryFromSexp for Vec<i32>
impl TryFromSexp for Vec<i32>
type Error = SexpTypeError
fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>
Source§impl TryFromSexp for Vec<i64>
impl TryFromSexp for Vec<i64>
Source§impl TryFromSexp for Vec<isize>
impl TryFromSexp for Vec<isize>
Source§impl TryFromSexp for Vec<u8>
impl TryFromSexp for Vec<u8>
type Error = SexpTypeError
fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>
Source§impl TryFromSexp for Vec<u16>
impl TryFromSexp for Vec<u16>
Source§impl TryFromSexp for Vec<u32>
impl TryFromSexp for Vec<u32>
Source§impl TryFromSexp for Vec<u64>
impl TryFromSexp for Vec<u64>
Source§impl TryFromSexp for Vec<usize>
impl TryFromSexp for Vec<usize>
Source§impl TryFromSexp for Vec<RLogical>
impl TryFromSexp for Vec<RLogical>
type Error = SexpTypeError
fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>
Source§impl TryFromSexp for Vec<Rcomplex>
impl TryFromSexp for Vec<Rcomplex>
type Error = SexpTypeError
fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>
Source§impl TryFromSexp for Vec<String>
Convert R character vector to Vec<String>.
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>.
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§impl TryFromSexp for Vec<PathBuf>
Convert R character vector (STRSXP) to Vec<PathBuf>.
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§impl TryFromSexp for HashSet<bool>
impl TryFromSexp for HashSet<bool>
Source§impl TryFromSexp for HashSet<i8>
impl TryFromSexp for HashSet<i8>
Source§impl TryFromSexp for HashSet<i16>
impl TryFromSexp for HashSet<i16>
Source§impl TryFromSexp for HashSet<i32>
impl TryFromSexp for HashSet<i32>
type Error = SexpTypeError
fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>
Source§impl TryFromSexp for HashSet<i64>
impl TryFromSexp for HashSet<i64>
Source§impl TryFromSexp for HashSet<isize>
impl TryFromSexp for HashSet<isize>
Source§impl TryFromSexp for HashSet<u8>
impl TryFromSexp for HashSet<u8>
type Error = SexpTypeError
fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>
Source§impl TryFromSexp for HashSet<u16>
impl TryFromSexp for HashSet<u16>
Source§impl TryFromSexp for HashSet<u32>
impl TryFromSexp for HashSet<u32>
Source§impl TryFromSexp for HashSet<u64>
impl TryFromSexp for HashSet<u64>
Source§impl TryFromSexp for HashSet<usize>
impl TryFromSexp for HashSet<usize>
Source§impl TryFromSexp for HashSet<RLogical>
impl TryFromSexp for HashSet<RLogical>
type Error = SexpTypeError
fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>
Source§impl TryFromSexp for HashSet<String>
Convert R character vector to HashSet<String>.
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.
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§impl TryFromSexp for PathBuf
Convert R character scalar (STRSXP of length 1) to PathBuf.
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§impl<T> TryFromSexp for &[T]where
T: RNativeType + Copy,
Blanket impl for &[T] where T: RNativeType
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§impl<T> TryFromSexp for &mut [T]where
T: RNativeType + Copy,
Blanket impl for &mut [T] where T: RNativeType
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§impl<T> TryFromSexp for Cow<'static, [T]>
Blanket impl: Convert R vector to Cow<'static, [T]> where T: RNativeType.
impl<T> TryFromSexp for Cow<'static, [T]>
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§impl<T> TryFromSexp for Option<&[T]>where
T: RNativeType + Copy,
Blanket impl for Option<&[T]> where T: RNativeType
impl<T> TryFromSexp for Option<&[T]>where
T: RNativeType + Copy,
Blanket impl for Option<&[T]> where T: RNativeType
Source§impl<T> TryFromSexp for Option<&mut [T]>where
T: RNativeType + Copy,
Blanket impl for Option<&mut [T]> where T: RNativeType
impl<T> TryFromSexp for Option<&mut [T]>where
T: RNativeType + Copy,
Blanket impl for Option<&mut [T]> where T: RNativeType
Source§impl<T> TryFromSexp for Option<BTreeSet<T>>
Convert R value to Option<BTreeSet<T>>: NULL -> None, otherwise Some(set).
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).
impl<T> TryFromSexp for Option<Vec<T>>
Convert R value to Option<Vec<T>>: NULL → None, otherwise Some(vec).
Source§impl<T> TryFromSexp for Option<HashSet<T>>
Convert R value to Option<HashSet<T>>: NULL -> None, otherwise Some(set).
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, ()>
impl<T> TryFromSexp for Result<T, ()>
Source§impl<T> TryFromSexp for BinaryHeap<T>
Blanket impl: Convert R vector to BinaryHeap<T> where T: RNativeType + Ord.
impl<T> TryFromSexp for BinaryHeap<T>
Blanket impl: Convert R vector to BinaryHeap<T> where T: RNativeType + Ord.
Creates a binary heap from the R vector elements.
Source§impl<T> TryFromSexp for VecDeque<T>where
T: RNativeType + Copy,
Blanket impl: Convert R vector to VecDeque<T> where T: RNativeType.
impl<T> TryFromSexp for VecDeque<T>where
T: RNativeType + Copy,
Blanket impl: Convert R vector to VecDeque<T> where T: RNativeType.
Source§impl<T> TryFromSexp for Vec<Vec<T>>
Convert R list (VECSXP) to Vec<Vec<T>>.
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§impl<T, const N: usize> TryFromSexp for [T; N]where
T: RNativeType + Copy,
Blanket impl: Convert R vector to [T; N] where T: RNativeType.
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§impl<T: TypedExternal + Send> TryFromSexp for Option<ExternalPtr<T>>
impl<T: TypedExternal + Send> TryFromSexp for Option<ExternalPtr<T>>
Source§impl<V: TryFromSexp> TryFromSexp for Option<BTreeMap<String, V>>
Convert R value to Option<BTreeMap<String, V>>: NULL -> None, otherwise Some(map).
impl<V: TryFromSexp> TryFromSexp for Option<BTreeMap<String, V>>
Convert R value to Option<BTreeMap<String, V>>: NULL -> None, otherwise Some(map).
Source§impl<V: TryFromSexp> TryFromSexp for Option<HashMap<String, V>>
Convert R value to Option<HashMap<String, V>>: NULL -> None, otherwise Some(map).
impl<V: TryFromSexp> TryFromSexp for Option<HashMap<String, V>>
Convert R value to Option<HashMap<String, V>>: NULL -> None, otherwise Some(map).
Source§impl<V: TryFromSexp> TryFromSexp for BTreeMap<String, V>
Convert R named list (VECSXP) to BTreeMap<String, V>.
impl<V: TryFromSexp> TryFromSexp for BTreeMap<String, V>
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>>
Convert R list of named lists to Vec<BTreeMap<String, V>>.
impl<V: TryFromSexp> TryFromSexp for Vec<BTreeMap<String, V>>
Convert R list of named lists to Vec<BTreeMap<String, V>>.
Source§impl<V: TryFromSexp> TryFromSexp for Vec<HashMap<String, V>>
Convert R list of named lists to Vec<HashMap<String, V>>.
impl<V: TryFromSexp> TryFromSexp for Vec<HashMap<String, V>>
Convert R list of named lists to Vec<HashMap<String, V>>.
Source§impl<V: TryFromSexp> TryFromSexp for HashMap<String, V>
Convert R named list (VECSXP) to HashMap<String, V>.
impl<V: TryFromSexp> TryFromSexp for HashMap<String, V>
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 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.
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.
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 AltrepSexp
Conversion from R SEXP to AltrepSexp.
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
impl TryFromSexp for DataFrameView
Source§impl TryFromSexp for SEXP
Pass-through conversion for raw SEXP values with ALTREP auto-materialization.
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
| Input | Result |
|---|---|
| Regular SEXP | Passed through unchanged |
| ALTREP SEXP | Materialized 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
impl TryFromSexp for List
type Error = ListFromSexpError
Source§impl TryFromSexp for ProtectedStrVec
impl TryFromSexp for ProtectedStrVec
Source§impl<T> TryFromSexp for Missing<T>
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.
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>.
impl<T: TypedExternal + Send> TryFromSexp for ExternalPtr<T>
Convert R EXTPTRSXP to ExternalPtr<T>.