Expand description
High-level ALTREP data traits.
These traits let you implement ALTREP behavior using &self methods instead of
raw SEXP callbacks. The library provides blanket implementations that handle
the SEXP extraction automatically.
§Quick Start
For common types, just use them directly:
ⓘ
// Vec<i32> already implements AltIntegerData
let altrep = create_altinteger(vec![1, 2, 3, 4, 5]);For custom types, implement the relevant trait:
ⓘ
struct Fibonacci { len: usize }
impl AltrepLen for Fibonacci {
fn len(&self) -> usize { self.len }
}
impl AltIntegerData for Fibonacci {
fn elt(&self, i: usize) -> i32 {
// Compute fibonacci(i)
unimplemented!()
}
}For simple field-based types, the Altrep* derive macros provide a shorter path:
they auto-implement AltrepLen and the matching Alt*Data trait, and can
optionally call the low-level impl_alt*_from_data! helpers.
Modules§
- builtins 🔒
- Built-in ALTREP data implementations for standard Rust types.
- core 🔒
- Core ALTREP data traits and helpers.
- iter 🔒
- Iterator-backed ALTREP data types.
- macros
- Helper macros for implementing ALTREP data traits.
Convenience macros for implementing
InferBase. - stream 🔒
- Streaming ALTREP data backed by chunk-cached reader closures.
- traits 🔒
- Per-family ALTREP data traits.
Structs§
- Iter
Complex Data - Iterator-backed complex number vector.
- Iter
IntCoerce Data - Iterator-backed integer vector with coercion from any integer-like type.
- Iter
IntData - Iterator-backed integer vector data.
- Iter
IntFrom Bool Data - Iterator-backed integer vector with coercion from bool.
- Iter
List Data - Iterator-backed list vector.
- Iter
Logical Data - Iterator-backed logical vector data.
- Iter
RawData - Iterator-backed raw (u8) vector data.
- Iter
Real Coerce Data - Iterator-backed real vector with coercion from any float-like type.
- Iter
Real Data - Iterator-backed real (f64) vector data.
- Iter
State - Core state for iterator-backed ALTREP vectors.
- Iter
String Data - Iterator-backed string vector.
- Sparse
Iter Complex Data - Sparse iterator-backed complex number vector.
- Sparse
Iter IntData - Sparse iterator-backed integer vector data.
- Sparse
Iter Logical Data - Sparse iterator-backed logical vector data.
- Sparse
Iter RawData - Sparse iterator-backed raw (u8) vector data.
- Sparse
Iter Real Data - Sparse iterator-backed real (f64) vector data.
- Sparse
Iter State - Core state for sparse iterator-backed ALTREP vectors.
- Streaming
IntData - Streaming ALTREP for integer (i32) vectors.
- Streaming
Real Data - Streaming ALTREP for real (f64) vectors.
- Windowed
Iter IntData - Windowed iterator-backed integer vector data.
- Windowed
Iter Real Data - Windowed iterator-backed real (f64) vector data.
- Windowed
Iter State - Core state for windowed iterator-backed ALTREP vectors.
Enums§
- Logical
- Logical value: TRUE, FALSE, or NA.
- Sortedness
- Sortedness hint for ALTREP vectors.
Traits§
- AltComplex
Data - Trait for types that can back an ALTCOMPLEX vector.
- AltInteger
Data - Trait for types that can back an ALTINTEGER vector.
- AltList
Data - Trait for types that can back an ALTLIST vector.
- AltLogical
Data - Trait for types that can back an ALTLOGICAL vector.
- AltRaw
Data - Trait for types that can back an ALTRAW vector.
- AltReal
Data - Trait for types that can back an ALTREAL vector.
- AltString
Data - Trait for types that can back an ALTSTRING vector.
- Altrep
Dataptr - Trait for ALTREP types that can expose a data pointer.
- Altrep
Extract - How to extract a reference to
Selffrom an ALTREP SEXP’s data1 slot. - Altrep
Extract Subset - Trait for ALTREP types that can provide optimized subsetting.
- Altrep
Len - Base trait for ALTREP data types. All ALTREP types must provide length.
- Altrep
Serialize - Trait for ALTREP types that support serialization.
- Infer
Base - Trait for inferring the R base type from a data type’s implemented traits.
Functions§
- materialize_
altrep_ ⚠data2 - Materialize an ALTREP SEXP into a plain R vector in data2.