#[doc(hidden)]#[repr(C)]pub struct ErasedObject<T> {
erased: mx_erased,
data: RefCell<T>,
}Expand description
Storage used by generated trait-ABI constructors.
The C header and concrete value retain their repr(C) layout. Keeping the
allocation and destructor here avoids emitting identical helper items for
every ExternalPtr derive. This is not ordinary ExternalPtr/Any storage, but
it keeps the value in a RefCell the same way: the method shims borrow it
for each call.
Fields§
§erased: mx_erased§data: RefCell<T>Implementations§
Source§impl<T> ErasedObject<T>
impl<T> ErasedObject<T>
Sourcepub const DATA_OFFSET: usize
pub const DATA_OFFSET: usize
Offset of the value’s RefCell, used by trait views, including
over-aligned concrete types.
Sourcepub unsafe fn into_raw(data: T, base: &'static mx_base_vtable) -> *mut mx_erased
pub unsafe fn into_raw(data: T, base: &'static mx_base_vtable) -> *mut mx_erased
Allocate an erased object with the generated type’s base vtable.
§Safety
base must describe T in this storage: its destructor must be
Self::drop_raw, its offset Self::DATA_OFFSET, and its query/tag
must identify the trait implementations of this concrete T.
Source§impl<T: TypedExternal> ErasedObject<T>
impl<T: TypedExternal> ErasedObject<T>
const SIDECAR_INIT: SidecarInitVTable
Sourcepub unsafe extern "C" fn query(
ptr: *mut mx_erased,
tag: mx_tag,
) -> *const c_void
pub unsafe extern "C" fn query( ptr: *mut mx_erased, tag: mx_tag, ) -> *const c_void
Query the concrete type’s traits and its optional sidecar initializer.
§Safety
ptr must be a live ErasedObject<T> with its matching base vtable.
The returned pointer is valid for the program’s lifetime and must be
cast to the interface identified by tag.
unsafe extern "C-unwind" fn init_sidecars( ptr: *mut mx_erased, owner: SEXP, )
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.