Skip to main content

TraitViewData

Struct TraitViewData 

Source
#[doc(hidden)]
pub struct TraitViewData<V> { data: *mut c_void, vtable: *const V, owner: Option<(SEXP, ProtectKey)>, }
Expand description

The checked construction boundary of a generated trait view.

Pointer fields live here, rather than in the expansion’s module: even code beside the generated view cannot construct or overwrite them safely. An R owner is rooted in the same pool as owning ExternalPtr handles, independently of the PROTECT stack, so views can outlive their creating scope and be dropped in any order. Raw pointers keep this type (and every generated view) !Send and !Sync.

Fields§

§data: *mut c_void§vtable: *const V§owner: Option<(SEXP, ProtectKey)>

Implementations§

Source§

impl<V> TraitViewData<V>

Source

pub unsafe fn new( data: *mut c_void, vtable: *const c_void, owner: Option<SEXP>, ) -> Self

Construct a view’s backing storage.

§Safety

data and vtable must be valid, non-null pointers matching the generated trait view. The vtable must outlive this value. When supplied, owner must own data; otherwise the caller must keep data alive. Calls must respect Rust’s aliasing rules. Construction, use and drop must run on R’s main thread, inside an R unwind boundary when allocating.

Source

pub fn data(&self) -> *mut c_void

The concrete data pointer, retaining its original mutable provenance.

Source

pub fn vtable(&self) -> *const V

The interface vtable. Dereferencing it remains an unsafe operation.

Source

pub fn owner(&self) -> Option<SEXP>

The rooted R receiver, which owner-receiver methods pass to their shim. None for a raw view built without an owner.

Trait Implementations§

Source§

impl<V> Drop for TraitViewData<V>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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: 40 bytes