#[repr(C)]pub struct mx_base_vtable {
pub drop: unsafe extern "C" fn(ptr: *mut mx_erased),
pub concrete_tag: mx_tag,
pub query: unsafe extern "C" fn(ptr: *mut mx_erased, trait_tag: mx_tag) -> *const c_void,
pub data_offset: usize,
}Expand description
Base vtable present in all erased objects.
This vtable provides the minimal operations needed for any erased object:
- Destructor for cleanup when R garbage collects the wrapper
- Concrete type tag for type-safe downcasts
- Query function to retrieve interface vtables
§Layout Guarantee
This type is #[repr(C)] and its layout is frozen. Fields will never
be reordered, and new fields will only be appended at the end.
§Generated By
#[derive(ExternalPtr)] emits a static instance of this vtable for each
wrapped type.
Fields§
§drop: unsafe extern "C" fn(ptr: *mut mx_erased)Destructor called when the R external pointer is garbage collected.
Receives a pointer to the erased object (not the data pointer). Must deallocate the entire erased wrapper structure.
§Safety
ptrmust be a valid pointer tomx_erasedallocated by this type’s constructor- Must only be called once per object
- Must be called on R’s main thread (during GC finalization)
concrete_tag: mx_tagTag identifying the concrete type wrapped by this object.
Used for type-safe downcasts: if concrete_tag matches the expected
type’s tag, the data pointer can be cast to that type.
query: unsafe extern "C" fn(ptr: *mut mx_erased, trait_tag: mx_tag) -> *const c_voidQuery function to retrieve interface vtables.
Given a trait tag, returns a pointer to the vtable for that interface, or null if the type does not implement that trait.
§Arguments
ptr- Pointer to the erased objecttrait_tag- Tag identifying the requested trait interface
§Returns
- Non-null pointer to the trait’s vtable if implemented
- Null pointer if the trait is not implemented
§Safety
ptrmust be a valid pointer tomx_erased- The returned pointer (if non-null) must be cast to the correct vtable type
data_offset: usizeByte offset from the start of the wrapper struct to the data field.
The generated wrapper struct is #[repr(C)] struct { erased: mx_erased, data: T }.
When T has stricter alignment than mx_erased, padding exists between
erased and data. This field records the correct offset so that
TraitView::try_from_sexp can compute the data pointer without
assuming offset == size_of::<mx_erased>().
Auto Trait Implementations§
impl Freeze for mx_base_vtable
impl RefUnwindSafe for mx_base_vtable
impl Send for mx_base_vtable
impl Sync for mx_base_vtable
impl Unpin for mx_base_vtable
impl UnsafeUnpin for mx_base_vtable
impl UnwindSafe for mx_base_vtable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> SizeEq<MaybeUninit<T>> for T
impl<T> SizeEq<MaybeUninit<T>> for T
type CastFrom = CastSizedExact
Source§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
ptr_alignment_type)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
sized_type_properties)[Self]. Read moreimpl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> InvariantsEq<ManuallyDrop<T>> for Twhere
T: ?Sized,
impl<T> InvariantsEq<T> for Twhere
T: ?Sized,
impl<T> InvariantsEq<Unalign<T>> for T
impl<T> InvariantsEq<Wrapping<T>> for T
impl<Src, Dst, A, SV, DV, R> MutationCompatible<Src, A, SV, DV, (BecauseRead, R)> for Dst
impl<Src, Dst, A, SV, DV> MutationCompatible<Src, A, SV, DV, BecauseInvariantsEq> for Dstwhere
A: Aliasing,
SV: Validity,
DV: Validity,
Src: TransmuteFrom<Dst, DV, SV> + ?Sized,
Dst: TransmuteFrom<Src, SV, DV> + InvariantsEq<Src> + ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> TransmuteFrom<Cell<T>, Valid, Valid> for Twhere
T: ?Sized,
impl<T> TransmuteFrom<ManuallyDrop<T>, Valid, Valid> for Twhere
T: ?Sized,
impl<T> TransmuteFrom<ReadOnly<T>, Valid, Valid> for Twhere
T: ?Sized,
impl<Src, Dst> TransmuteFrom<Src, Initialized, Initialized> for Dst
impl<Src, Dst, V> TransmuteFrom<Src, V, Uninit> for Dst
impl<Src, Dst> TransmuteFrom<Src, Valid, Initialized> for Dst
impl<T> TransmuteFrom<Unalign<T>, Valid, Valid> for T
impl<T> TransmuteFrom<UnsafeCell<T>, Valid, Valid> for Twhere
T: ?Sized,
impl<T> TransmuteFrom<Wrapping<T>, Valid, Valid> for T
impl<Src, Dst, A, SV, DV, C, R> TransmuteFromPtr<Src, A, SV, DV, C, R> for Dstwhere
A: Aliasing,
SV: Validity,
DV: Validity,
C: CastExact<Src, Dst>,
Dst: TransmuteFrom<Src, SV, DV> + TryTransmuteFromPtr<Src, A, SV, DV, C, R> + ?Sized,
Src: ?Sized,
impl<Src, Dst, SV, DV, A, C, R> TryTransmuteFromPtr<Src, A, SV, DV, C, (BecauseMutationCompatible, R)> for Dstwhere
A: Aliasing,
SV: Validity,
DV: Validity,
Src: TransmuteFrom<Dst, DV, SV> + ?Sized,
Dst: MutationCompatible<Src, A, SV, DV, R> + ?Sized,
C: CastExact<Src, Dst>,
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