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 (the NA_REAL bit pattern) yields None, matching as_i32.

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) -> RValue

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 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 = Infallible

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§

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

Convert from SEXP without thread safety checks. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> RClone for T
where T: Clone,

Source§

fn clone(&self) -> T

Create a deep copy of this value.
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§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 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