[−][src]Struct rel_ptr::RelPtr
This represents a relative pointers
A relative pointer stores an offset, and uses its that in combination with its current position in memory to point to a value
See crate documentation for more information
Methods
impl<T: ?Sized + MetaData, I: Delta> RelPtr<T, I>
[src]
pub fn null() -> Self
[src]
A null relative pointer has an offset of 0, (points to itself)
pub fn is_null(&self) -> bool
[src]
Check if relative pointer is null
pub fn set(&mut self, value: &T) -> Result<(), I::Error>
[src]
set the offset of a relative pointer,
if the offset cannot be calculated using the given
Delta
, then None
will be returned, and there will be
no change to the offset
pub unsafe fn set_unchecked(&mut self, value: &T)
[src]
set the offset of a relative pointer,
if the offset cannot be calculated using the given
Delta
, then None
will be returned, and there will be
no change to the offset
Safety
if the offset is out of bounds for the given Delta
then it's value is UB
pub unsafe fn as_raw(&self) -> *mut T
[src]
Converts the relative pointer into a normal raw pointer
Note: if self.is_null()
then a null pointer will be returned
Safety
You must ensure that if RelPtr::set
was called successfully before
calling this function and that the value pointed to does not change it's
offset relative to RelPtr
if RelPtr::set
was never called successfully, this function is safe and returns
None
because the only way to construct a RelPtr
is to make a null ptr and change it
through RelPtr::set
pub unsafe fn as_raw_unchecked(&self) -> *mut T
[src]
Converts the relative pointer into a normal raw pointer
Safety
You must ensure that RelPtr::set
was called successfully before
calling this function and that the value pointed to does not change it's
offset relative to RelPtr
if RelPtr::set
was never called successfully, this function is UB
pub unsafe fn as_non_null(&self) -> Option<NonNull<T>>
[src]
pub unsafe fn as_non_null_unchecked(&self) -> NonNull<T>
[src]
pub unsafe fn as_ref(&self) -> Option<&T>
[src]
Gets a reference from the relative pointer,
if the relative pointer is null, then None
is
returned
Safety
Same as RelPtr::as_raw
pub unsafe fn as_mut(&mut self) -> Option<&mut T>
[src]
Gets a mutable reference from the relative pointer,
if the relative pointer is null, then None
is
returned
Safety
Same as RelPtr::as_raw
pub unsafe fn as_ref_unchecked(&self) -> &T
[src]
pub unsafe fn as_mut_unchecked(&mut self) -> &mut T
[src]
Trait Implementations
impl<T: ?Sized + MetaData, I: Delta> Copy for RelPtr<T, I>
[src]
impl<T: ?Sized + MetaData, I: Delta> PartialEq<RelPtr<T, I>> for RelPtr<T, I>
[src]
fn eq(&self, other: &Self) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<T: ?Sized + MetaData, I: Delta> Clone for RelPtr<T, I>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: ?Sized + MetaData, I: Delta> Eq for RelPtr<T, I>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> MetaData for T
[src]
type Data = ()
the type of meta data a type carries
fn decompose(&T) -> (*const u8, <T as MetaData>::Data)
[src]
unsafe fn compose(*const u8, <T as MetaData>::Data) -> *mut T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,