#[repr(C)]pub struct RelPtr<T: BasisPointee<B> + ?Sized, R: Region, B: Basis> { /* private fields */ }
Expand description
A pointer that stores the difference between itself and its pointee.
Implementations
sourceimpl<T: BasisPointee<B> + ?Sized, R: Region, B: Basis> RelPtr<T, R, B>
impl<T: BasisPointee<B> + ?Sized, R: Region, B: Basis> RelPtr<T, R, B>
sourcepub fn base(this: Ref<'_, Self>) -> *const u8
pub fn base(this: Ref<'_, Self>) -> *const u8
Returns the base pointer for the relative pointer.
The base of the relative pointer is always its location in memory.
sourcepub fn base_mut(this: Mut<'_, Self>) -> *mut u8
pub fn base_mut(this: Mut<'_, Self>) -> *mut u8
Returns the mutable base pointer for the relative pointer.
The base of the relative pointer is always its location in memory.
sourcepub fn offset(&self) -> isize
pub fn offset(&self) -> isize
Returns the offset of the relative pointer’s target from its base.
sourcepub fn metadata(&self) -> Option<T::Metadata>
pub fn metadata(&self) -> Option<T::Metadata>
Returns the metadata of the relative pointer’s pointee if it is not null.
sourcepub unsafe fn metadata_unchecked(&self) -> T::Metadata
pub unsafe fn metadata_unchecked(&self) -> T::Metadata
Returns the metadata of the relative pointer’s pointee.
Safety
The relative pointer must not be null.
sourcepub fn as_ptr(this: Ref<'_, Self>) -> Option<*const T>
pub fn as_ptr(this: Ref<'_, Self>) -> Option<*const T>
Returns the target of the relative pointer if it is not null.
sourcepub unsafe fn as_ptr_unchecked(this: Ref<'_, Self>) -> *const T
pub unsafe fn as_ptr_unchecked(this: Ref<'_, Self>) -> *const T
sourcepub unsafe fn as_ref<'a>(this: Ref<'_, Self>) -> Ref<'a, T>
pub unsafe fn as_ref<'a>(this: Ref<'_, Self>) -> Ref<'a, T>
Returns a Ref
to the target of the relative pointer.
Safety
this
must be non-null, properly aligned, and valid for reads.this
must not alias any other mutable references for'a
.- The value pointed to by
this
must be initialized.
sourcepub fn as_mut_ptr(this: Mut<'_, Self>) -> Option<*mut T>
pub fn as_mut_ptr(this: Mut<'_, Self>) -> Option<*mut T>
Returns a mutable pointer to the target of the relative pointer if it is not null.
sourcepub unsafe fn as_mut_ptr_unchecked(this: Mut<'_, Self>) -> *mut T
pub unsafe fn as_mut_ptr_unchecked(this: Mut<'_, Self>) -> *mut T
sourcepub unsafe fn as_mut<'a>(this: Mut<'_, Self>) -> Mut<'a, T>
pub unsafe fn as_mut<'a>(this: Mut<'_, Self>) -> Mut<'a, T>
Returns a Mut
to the target of the relative pointer.
Safety
this
must be non-null, properly aligned, and valid for reads and writes.this
must not alias any other accessible references for'a
.- The pointee of
this
must be initialized and immovable.