pub unsafe trait HasVPtr<Trait: ?Sized> {
// Required methods
fn init() -> &'static VTableData;
fn get_vptr(&self) -> &VPtr<Self, Trait>
where Self: Sized;
fn get_vptr_mut(&mut self) -> &mut VPtr<Self, Trait>
where Self: Sized;
// Provided methods
fn as_thin_ref(&self) -> ThinRef<'_, Trait>
where Self: Sized { ... }
fn as_thin_ref_mut(&mut self) -> ThinRefMut<'_, Trait>
where Self: Sized { ... }
fn as_pin_thin_ref(self: Pin<&Self>) -> Pin<ThinRef<'_, Trait>>
where Self: Sized { ... }
fn as_pin_thin_ref_mut(self: Pin<&mut Self>) -> Pin<ThinRefMut<'_, Trait>>
where Self: Sized { ... }
}Expand description
This trait indicate that the type has a VPtr field to the trait Trait
You should not implement this trait yourself, it is implemented by the vptr macro
Safety: For this to work correctly, the init() function must return a reference to a VTableData with valid content (the offset and vtable pointer need to be correct for this type) and get_vptr must return a reference of a field withi &self. The `#vptr macro does the right thing
Required Methods§
Sourcefn init() -> &'static VTableData
fn init() -> &'static VTableData
Initialize a VTableData suitable to initialize the VPtr within Self
Sourcefn get_vptr(&self) -> &VPtr<Self, Trait>where
Self: Sized,
fn get_vptr(&self) -> &VPtr<Self, Trait>where
Self: Sized,
return the a reference of the VPtr within Self
Sourcefn get_vptr_mut(&mut self) -> &mut VPtr<Self, Trait>where
Self: Sized,
fn get_vptr_mut(&mut self) -> &mut VPtr<Self, Trait>where
Self: Sized,
return the a reference of the VPtr within Self
Provided Methods§
Sourcefn as_thin_ref(&self) -> ThinRef<'_, Trait>where
Self: Sized,
fn as_thin_ref(&self) -> ThinRef<'_, Trait>where
Self: Sized,
return a thin reference to self
Sourcefn as_thin_ref_mut(&mut self) -> ThinRefMut<'_, Trait>where
Self: Sized,
fn as_thin_ref_mut(&mut self) -> ThinRefMut<'_, Trait>where
Self: Sized,
return a thin reference to self
Sourcefn as_pin_thin_ref(self: Pin<&Self>) -> Pin<ThinRef<'_, Trait>>where
Self: Sized,
fn as_pin_thin_ref(self: Pin<&Self>) -> Pin<ThinRef<'_, Trait>>where
Self: Sized,
Map a pinned reference to to a pinned thin reference
Sourcefn as_pin_thin_ref_mut(self: Pin<&mut Self>) -> Pin<ThinRefMut<'_, Trait>>where
Self: Sized,
fn as_pin_thin_ref_mut(self: Pin<&mut Self>) -> Pin<ThinRefMut<'_, Trait>>where
Self: Sized,
Map a pinned mutable reference to to a pinned mutable thin reference
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.