Trait rmin::SExt

source ·
pub trait SExt: Sized {
    type Data: RType;

    // Required methods
    fn as_sexp(&self) -> *mut SEXPREC;
    fn new(len: <Self::Data as RType>::New) -> Self
       where Self: Newable;

    // Provided methods
    fn is_correct_type(&self) -> bool { ... }
    fn len(&self) -> usize { ... }
    unsafe fn data_unchecked(&self) -> &[<Self::Data as RType>::Data] { ... }
    fn data(&self) -> &[<Self::Data as RType>::Data] { ... }
    unsafe fn data_unchecked_mut(&self) -> &mut [<Self::Data as RType>::Data]
       where <Self as SExt>::Data: RTypeMut,
             Self: Mutable { ... }
    fn data_mut(&mut self) -> &mut [<Self::Data as RType>::Data]
       where <Self as SExt>::Data: RTypeMut,
             Self: Mutable { ... }
}
Expand description

SEXP extensions

Contains all the operation that a normal SEXP could execute.

Required Associated Types§

source

type Data: RType

SEXP Associated data, normally double->f64, integer->i32, logical->u32, character->u8, Other data might be added in the future.

Required Methods§

source

fn as_sexp(&self) -> *mut SEXPREC

get the inner SEXP.

source

fn new(len: <Self::Data as RType>::New) -> Self
where Self: Newable,

allocate a new SEXP object with length for u8 (CHARcrate::libR::SEXP), new with length is not allowed thus CHARcrate::libR::SEXP accept a String object.

Provided Methods§

source

fn is_correct_type(&self) -> bool

check whether the data has the desired type

source

fn len(&self) -> usize

get length of this SEXP.

source

unsafe fn data_unchecked(&self) -> &[<Self::Data as RType>::Data]

got the read-only data of a SEXP object SAFETY: caller should ensure this SEXP has data with

  1. SEXP.is_correct_type()
  2. Self::Data::len(sexp)>0
source

fn data(&self) -> &[<Self::Data as RType>::Data]

got the read-only data of a SEXP object

source

unsafe fn data_unchecked_mut(&self) -> &mut [<Self::Data as RType>::Data]
where <Self as SExt>::Data: RTypeMut, Self: Mutable,

got the read-only data of a SEXP object SAFETY: caller should ensure this SEXP has data with

  1. SEXP.is_correct_type()
  2. Self::Data::len(sexp)>0
source

fn data_mut(&mut self) -> &mut [<Self::Data as RType>::Data]
where <Self as SExt>::Data: RTypeMut, Self: Mutable,

got the read-only data of a SEXP object

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T: RType> SExt for Owned<T>

§

type Data = T

source§

impl<T: RType> SExt for SEXP<T>

§

type Data = T