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 altrep_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.
Re-exports§
pub use buffer::AltrepBuffer;pub use core::AltrepDataptr;pub use core::AltrepExtract;pub use core::AltrepExtractSubset;pub use core::AltrepLen;pub use core::AltrepSerialize;pub use core::InferBase;pub use core::Logical;pub use core::Sortedness;pub use core::altrep_values_written;pub use core::materialize_altrep_data2;pub use core::materialized_altrep_data2;pub use core::materialized_altrep_region;pub use iter::*;pub use stream::*;pub use traits::*;
Modules§
- buffer 🔒
- Native Vec ownership that preserves allocations already exposed to R.
- builtins 🔒
- Built-in ALTREP data implementations for standard Rust types.
- core 🔒
- Core ALTREP data traits and helpers.
- deque 🔒
- ALTREP storage for native-element ring buffers.
- iter 🔒
- Iterator-backed ALTREP data adaptors.
- macros
- Helper macros for implementing ALTREP data traits.
Convenience macros for implementing
InferBase. - stream 🔒
- Streaming ALTREP data adaptors backed by chunk-cached reader closures.
- traits 🔒
- Per-family ALTREP data traits.