pub trait Altrep {
const GUARD: AltrepGuard = AltrepGuard::RUnwind;
const HAS_SERIALIZED_STATE: bool = false;
const HAS_UNSERIALIZE: bool = false;
const HAS_UNSERIALIZE_EX: bool = false;
const HAS_DUPLICATE: bool = false;
const HAS_DUPLICATE_EX: bool = false;
const HAS_COERCE: bool = false;
const HAS_INSPECT: bool = false;
// Required method
fn length(x: SEXP) -> R_xlen_t;
// Provided methods
fn serialized_state(_x: SEXP) -> SEXP { ... }
fn unserialize(_class: SEXP, _state: SEXP) -> SEXP { ... }
fn unserialize_ex(
_class: SEXP,
_state: SEXP,
_attr: SEXP,
_objf: i32,
_levs: i32,
) -> SEXP { ... }
fn duplicate(_x: SEXP, _deep: bool) -> SEXP { ... }
fn duplicate_ex(_x: SEXP, _deep: bool) -> SEXP { ... }
fn coerce(_x: SEXP, _to_type: SEXPTYPE) -> SEXP { ... }
fn inspect(
_x: SEXP,
_pre: i32,
_deep: i32,
_pvec: i32,
_inspect_subtree: Option<unsafe extern "C-unwind" fn(SEXP, i32, i32, i32)>,
) -> bool { ... }
}Expand description
Base ALTREP methods.
length is REQUIRED (no default). All other methods are optional with HAS_* gating.
Provided Associated Constants§
Sourceconst GUARD: AltrepGuard = AltrepGuard::RUnwind
const GUARD: AltrepGuard = AltrepGuard::RUnwind
The guard mode for all ALTREP trampolines on this type.
Defaults to AltrepGuard::RUnwind which catches both Rust panics and
R longjmps via R_UnwindProtect. This is safe for all callbacks, including
those that call R API functions (e.g., Rf_mkCharLenCE, Rf_ScalarReal,
into_sexp in serialization).
Override to AltrepGuard::RustUnwind if your callbacks never call R APIs
and you want to save ~2ns per call, or AltrepGuard::Unsafe for trivial
callbacks that cannot panic.
Sourceconst HAS_SERIALIZED_STATE: bool = false
const HAS_SERIALIZED_STATE: bool = false
Set to true to register serialized_state.
Sourceconst HAS_UNSERIALIZE: bool = false
const HAS_UNSERIALIZE: bool = false
Set to true to register unserialize.
Sourceconst HAS_UNSERIALIZE_EX: bool = false
const HAS_UNSERIALIZE_EX: bool = false
Set to true to register unserialize_ex.
Sourceconst HAS_DUPLICATE: bool = false
const HAS_DUPLICATE: bool = false
Set to true to register duplicate.
Sourceconst HAS_DUPLICATE_EX: bool = false
const HAS_DUPLICATE_EX: bool = false
Set to true to register duplicate_ex.
Sourceconst HAS_COERCE: bool = false
const HAS_COERCE: bool = false
Set to true to register coerce.
Sourceconst HAS_INSPECT: bool = false
const HAS_INSPECT: bool = false
Set to true to register inspect.
Required Methods§
Provided Methods§
Sourcefn serialized_state(_x: SEXP) -> SEXP
fn serialized_state(_x: SEXP) -> SEXP
Return serialization state.
Sourcefn unserialize(_class: SEXP, _state: SEXP) -> SEXP
fn unserialize(_class: SEXP, _state: SEXP) -> SEXP
Reconstruct ALTREP from serialized state.
Sourcefn unserialize_ex(
_class: SEXP,
_state: SEXP,
_attr: SEXP,
_objf: i32,
_levs: i32,
) -> SEXP
fn unserialize_ex( _class: SEXP, _state: SEXP, _attr: SEXP, _objf: i32, _levs: i32, ) -> SEXP
Extended unserialization with attributes.
Sourcefn duplicate_ex(_x: SEXP, _deep: bool) -> SEXP
fn duplicate_ex(_x: SEXP, _deep: bool) -> SEXP
Extended duplication.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.