Skip to main content

RValue

Enum RValue 

Source
pub enum RValue {
    Null,
    Logical(Vec<Option<bool>>),
    Integer(Vec<Option<i32>>),
    Double(Vec<f64>),
    Complex(Vec<Rcomplex>),
    Character(Vec<Option<String>>),
    Raw(Vec<u8>),
    List(Vec<(Option<String>, RValue)>),
}
Expand description

An owned, Send, R-native value tree. See the module docs.

Variants§

§

Null

NULL (NILSXP).

§

Logical(Vec<Option<bool>>)

Logical vector (LGLSXP). None is NA.

§

Integer(Vec<Option<i32>>)

Integer vector (INTSXP). None is NA.

§

Double(Vec<f64>)

Double vector (REALSXP). NA is carried in the NA_REAL bit pattern.

§

Complex(Vec<Rcomplex>)

Complex vector (CPLXSXP).

§

Character(Vec<Option<String>>)

Character vector (STRSXP). None is NA.

§

Raw(Vec<u8>)

Raw byte vector (RAWSXP). No NA.

§

List(Vec<(Option<String>, RValue)>)

Generic list (VECSXP). Recursive; a None name is an unnamed slot.

Implementations§

Source§

impl RValue

Source

pub fn sexptype(&self) -> SEXPTYPE

The SEXPTYPE this value materialises to via IntoR.

Source

pub fn is_null(&self) -> bool

true if this is RValue::Null.

Source

pub fn debug<T: Debug>(value: T) -> Self

Wrap any T: Debug as a length-1 Character carrying its {:?} rendering — the escape hatch for a value with no R-native mapping (e.g. a Rust range). The rendering happens eagerly here, so nothing borrows across the Send boundary a condition payload crosses.

ⓘ
assert_eq!(RValue::debug(0..=100).as_str(), Some("0..=100"));
Source

pub fn as_i32(&self) -> Option<i32>

The single non-NA i32 of a length-1 Integer, else None.

Returns None for the wrong variant, a length other than 1, or NA — the borrow-friendly counterpart to i32::try_from when you don’t need to know why it failed.

Source

pub fn as_f64(&self) -> Option<f64>

The single non-NA f64 of a length-1 Double, else None.

R’s NA yields None, matching as_i32. NA is decided by R’s R_IsNA rule, so a computed NA (NA_real_ * 1) counts; any other NaN is returned as a value.

Source

pub fn as_bool(&self) -> Option<bool>

The single non-NA bool of a length-1 Logical, else None.

Source

pub fn as_str(&self) -> Option<&str>

The single non-NA string of a length-1 Character, else None.

Trait Implementations§

Source§

impl Clone for RValue

Source§

fn clone(&self) -> Self

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 RValue

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<&str> for RValue

Source§

fn from(v: &str) -> Self

Converts to this type from the input type.
Source§

impl<A: Into<RValue>, B: Into<RValue>> From<(A, B)> for RValue

Source§

fn from(value: (A, B)) -> Self

Converts to this type from the input type.
Source§

impl<A: Into<RValue>, B: Into<RValue>, C: Into<RValue>> From<(A, B, C)> for RValue

Source§

fn from(value: (A, B, C)) -> Self

Converts to this type from the input type.
Source§

impl<A: Into<RValue>, B: Into<RValue>, C: Into<RValue>, D: Into<RValue>> From<(A, B, C, D)> for RValue

Source§

fn from(value: (A, B, C, D)) -> Self

Converts to this type from the input type.
Source§

impl<A: Into<RValue>, B: Into<RValue>, C: Into<RValue>, D: Into<RValue>, E: Into<RValue>> From<(A, B, C, D, E)> for RValue

Source§

fn from(value: (A, B, C, D, E)) -> Self

Converts to this type from the input type.
Source§

impl<A: Into<RValue>, B: Into<RValue>, C: Into<RValue>, D: Into<RValue>, E: Into<RValue>, F: Into<RValue>> From<(A, B, C, D, E, F)> for RValue

Source§

fn from(value: (A, B, C, D, E, F)) -> Self

Converts to this type from the input type.
Source§

impl<A: Into<RValue>, B: Into<RValue>, C: Into<RValue>, D: Into<RValue>, E: Into<RValue>, F: Into<RValue>, G: Into<RValue>> From<(A, B, C, D, E, F, G)> for RValue

Source§

fn from(value: (A, B, C, D, E, F, G)) -> Self

Converts to this type from the input type.
Source§

impl<A: Into<RValue>, B: Into<RValue>, C: Into<RValue>, D: Into<RValue>, E: Into<RValue>, F: Into<RValue>, G: Into<RValue>, H: Into<RValue>> From<(A, B, C, D, E, F, G, H)> for RValue

Source§

fn from(value: (A, B, C, D, E, F, G, H)) -> Self

Converts to this type from the input type.
Source§

impl<A: Into<RValue>, B: Into<RValue>, C: Into<RValue>, D: Into<RValue>, E: Into<RValue>, F: Into<RValue>, G: Into<RValue>, H: Into<RValue>, I: Into<RValue>> From<(A, B, C, D, E, F, G, H, I)> for RValue

Source§

fn from(value: (A, B, C, D, E, F, G, H, I)) -> Self

Converts to this type from the input type.
Source§

impl<A: Into<RValue>, B: Into<RValue>, C: Into<RValue>, D: Into<RValue>, E: Into<RValue>, F: Into<RValue>, G: Into<RValue>, H: Into<RValue>, I: Into<RValue>, J: Into<RValue>> From<(A, B, C, D, E, F, G, H, I, J)> for RValue

Source§

fn from(value: (A, B, C, D, E, F, G, H, I, J)) -> Self

Converts to this type from the input type.
Source§

impl<A: Into<RValue>, B: Into<RValue>, C: Into<RValue>, D: Into<RValue>, E: Into<RValue>, F: Into<RValue>, G: Into<RValue>, H: Into<RValue>, I: Into<RValue>, J: Into<RValue>, K: Into<RValue>> From<(A, B, C, D, E, F, G, H, I, J, K)> for RValue

Source§

fn from(value: (A, B, C, D, E, F, G, H, I, J, K)) -> Self

Converts to this type from the input type.
Source§

impl<A: Into<RValue>, B: Into<RValue>, C: Into<RValue>, D: Into<RValue>, E: Into<RValue>, F: Into<RValue>, G: Into<RValue>, H: Into<RValue>, I: Into<RValue>, J: Into<RValue>, K: Into<RValue>, L: Into<RValue>> From<(A, B, C, D, E, F, G, H, I, J, K, L)> for RValue

Source§

fn from(value: (A, B, C, D, E, F, G, H, I, J, K, L)) -> Self

Converts to this type from the input type.
Source§

impl<A: Into<RValue>> From<(A,)> for RValue

Source§

fn from(value: (A,)) -> Self

Converts to this type from the input type.
Source§

impl From<Option<&str>> for RValue

Source§

fn from(v: Option<&str>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<String>> for RValue

Source§

fn from(v: Option<String>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<bool>> for RValue

Source§

fn from(v: Option<bool>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<f64>> for RValue

Source§

fn from(v: Option<f64>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<i32>> for RValue

Source§

fn from(v: Option<i32>) -> Self

Converts to this type from the input type.
Source§

impl From<String> for RValue

Source§

fn from(v: String) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<&str>> for RValue

Source§

fn from(v: Vec<&str>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Option<&str>>> for RValue

Source§

fn from(v: Vec<Option<&str>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Option<String>>> for RValue

Source§

fn from(v: Vec<Option<String>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Option<bool>>> for RValue

Source§

fn from(v: Vec<Option<bool>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Option<f64>>> for RValue

Source§

fn from(v: Vec<Option<f64>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Option<i32>>> for RValue

Source§

fn from(v: Vec<Option<i32>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<String>> for RValue

Source§

fn from(v: Vec<String>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<bool>> for RValue

Source§

fn from(v: Vec<bool>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<f64>> for RValue

Source§

fn from(v: Vec<f64>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<i32>> for RValue

Source§

fn from(v: Vec<i32>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for RValue

Source§

fn from(v: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for RValue

Source§

fn from(v: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for RValue

Source§

fn from(v: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for RValue

Wide-integer ladder: an i64 (or u32) that fits in i32 and is not i32::MIN (R’s NA_integer_) becomes an Integer; anything else becomes a Double. Mirrors R’s own integer→double promotion for out-of-range values.

Source§

fn from(v: i64) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for RValue

Source§

fn from(v: u32) -> Self

Lossless widening to i64, then the shared ladder. A u32 is never i32::MIN as an i32, so only the > i32::MAX case falls to Double.

Source§

impl IntoR for RValue

Source§

type Error = !

The error type for fallible conversions. Read more
Source§

fn try_into_sexp(self) -> Result<SEXP, Self::Error>

Try to convert this value to an R SEXP. Read more
Source§

unsafe fn try_into_sexp_unchecked(self) -> Result<SEXP, Self::Error>

Try to convert to SEXP without thread safety checks. Read more
Source§

fn into_sexp(self) -> SEXP

Convert this value to an R SEXP, panicking on error. Read more
Source§

unsafe fn into_sexp_unchecked(self) -> SEXP
where Self: Sized,

Convert to SEXP without thread safety checks, panicking on error. Read more
Source§

impl TryFrom<RValue> for i32

Source§

type Error = SexpError

The type returned in the event of a conversion error.
Source§

fn try_from(value: RValue) -> Result<Self, SexpError>

Performs the conversion.
Source§

impl TryFrom<RValue> for bool

Source§

type Error = SexpError

The type returned in the event of a conversion error.
Source§

fn try_from(value: RValue) -> Result<Self, SexpError>

Performs the conversion.
Source§

impl TryFrom<RValue> for String

Source§

type Error = SexpError

The type returned in the event of a conversion error.
Source§

fn try_from(value: RValue) -> Result<Self, SexpError>

Performs the conversion.
Source§

impl TryFrom<RValue> for f64

Source§

type Error = SexpError

The type returned in the event of a conversion error.
Source§

fn try_from(value: RValue) -> Result<Self, SexpError>

Performs the conversion.
Source§

impl TryFrom<RValue> for Vec<Option<bool>>

Source§

type Error = SexpError

The type returned in the event of a conversion error.
Source§

fn try_from(value: RValue) -> Result<Self, SexpError>

Performs the conversion.
Source§

impl TryFrom<RValue> for Vec<Option<i32>>

Source§

type Error = SexpError

The type returned in the event of a conversion error.
Source§

fn try_from(value: RValue) -> Result<Self, SexpError>

Performs the conversion.
Source§

impl TryFrom<RValue> for Vec<f64>

Source§

type Error = SexpError

The type returned in the event of a conversion error.
Source§

fn try_from(value: RValue) -> Result<Self, SexpError>

Performs the conversion.
Source§

impl TryFrom<RValue> for Vec<Rcomplex>

Source§

type Error = SexpError

The type returned in the event of a conversion error.
Source§

fn try_from(value: RValue) -> Result<Self, SexpError>

Performs the conversion.
Source§

impl TryFrom<RValue> for Vec<Option<String>>

Source§

type Error = SexpError

The type returned in the event of a conversion error.
Source§

fn try_from(value: RValue) -> Result<Self, SexpError>

Performs the conversion.
Source§

impl TryFrom<RValue> for Vec<u8>

Source§

type Error = SexpError

The type returned in the event of a conversion error.
Source§

fn try_from(value: RValue) -> Result<Self, SexpError>

Performs the conversion.
Source§

impl TryFrom<RValue> for Vec<(Option<String>, RValue)>

Source§

type Error = SexpError

The type returned in the event of a conversion error.
Source§

fn try_from(value: RValue) -> Result<Self, SexpError>

Performs the conversion.
Source§

impl TryFromSexp for RValue

Source§

type Error = SexpError

The error type returned when conversion fails.
Source§

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

Attempt to convert an R SEXP to this Rust type. Read more
Source§

const NATIVE_BORROW: Option<NativeBorrow> = None

Native vector storage retained by this conversion, if any. Read more
Source§

const CHARACTER_ONLY: bool = false

Whether this conversion accepts only character input: every value it converts, other than NULL, is a character vector or a factor. Read more
Source§

#[doc(hidden)]
const __MX_EXPECTATION: Option<&'static str> = None

What an argument of this type must be, in R terms, when #[miniextendr] cannot tell from the type as written: the <expected> of a failed conversion’s '<p>' must be <expected>: .... Read more
Source§

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

Convert from SEXP without thread safety checks. Read more
Source§

#[doc(hidden)]
unsafe fn __mx_try_from_rooted(root: Root<'_>) -> Result<Self, Self::Error>

Convert with a scope able to retain uncached ALTREP elements. Custom reference converters keep their existing behavior by default. Read more
Source§

#[doc(hidden)]
fn __mx_has_na(&self) -> bool

Whether the converted argument holds a value #[miniextendr(no_na)] refuses after the conversion. Read more
Source§

#[doc(hidden)]
fn __mx_input_has_na(&self, input: SEXP) -> bool

Whether #[miniextendr(no_na)] refuses this converted argument, read from input (the R value it converted from), when no R guard ran. Read more
Source§

#[doc(hidden)]
fn __mx_try_from_sexp_with_check( sexp: SEXP, check: &ElementCheck<'_>, ) -> Result<Self, SexpError>
where Self::Error: Into<SexpError>,

Convert, running check, an element type’s TryFromSexpElement::check_sexp, on the R value that carries an element’s class (#1837). Read more
Source§

#[doc(hidden)]
unsafe fn __mx_try_from_sexp_unchecked_with_check( sexp: SEXP, check: &ElementCheck<'_>, ) -> Result<Self, SexpError>
where Self::Error: Into<SexpError>,

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

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

Source§

fn r_clone(&self) -> T

Create a deep copy of this value.
Source§

#[doc(hidden)]
unsafe extern "C" fn __RClone_r_clone_shim( data: *mut c_void, argc: i32, argv: *const SEXP, ) -> SEXP
where Self: Sized + RClone + IntoR,

Method shim for RClone::r_clone. Read more
Source§

impl<T> RDebug for T
where T: Debug,

Source§

fn debug_str(&self) -> String

Get a compact debug string representation.
Source§

fn debug_str_pretty(&self) -> String

Get a pretty-printed debug string with indentation.
Source§

#[doc(hidden)]
unsafe extern "C" fn __RDebug_debug_str_shim( data: *mut c_void, argc: i32, argv: *const SEXP, ) -> SEXP
where Self: Sized + RDebug,

Method shim for RDebug::debug_str. Read more
Source§

#[doc(hidden)]
unsafe extern "C" fn __RDebug_debug_str_pretty_shim( data: *mut c_void, argc: i32, argv: *const SEXP, ) -> SEXP
where Self: Sized + RDebug,

Method shim for RDebug::debug_str_pretty. Read more
Source§

impl<T> SizeHint for T
where T: ?Sized,

Source§

default fn lower_bound(&self) -> usize

🔬This is a nightly-only experimental API. (core_io_internals)
Returns a lower bound on the number of elements this container-like item contains. For example, an array [u8; 12] could return any value between 0 and 12 inclusively as a correct implementation. Read more
Source§

default fn upper_bound(&self) -> Option<usize>

🔬This is a nightly-only experimental API. (core_io_internals)
Returns an upper bound on the number of elements this container-like item contains if it can be determined, otherwise None. Read more
Source§

final fn size_hint(&self) -> (usize, Option<usize>)

🔬This is a nightly-only experimental API. (core_io_internals)
Returns an estimate for the number of elements this container like type contains. Read more
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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: 32 bytes

Size for each variant:

  • Null: 0 bytes
  • Logical: 24 bytes
  • Integer: 24 bytes
  • Double: 24 bytes
  • Complex: 24 bytes
  • Character: 24 bytes
  • Raw: 24 bytes
  • List: 24 bytes