[][src]Struct rel_ptr::RelPtr

pub struct RelPtr<T: ?Sized + MetaData, I: Delta = isize>(_, _, _);

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 Err 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,

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 the relative pointer was successfully set then the value pointed to does not change it's offset relative to RelPtr

if the relative pointer was not successfully set RelPtr::as_raw returns null, this function is safe for all types except for trait objects because the only way to construct a RelPtr is to make a null ptr and change it through RelPtr::set, but with trait objects it is impossible to create a v-table so it will have an invalid v-table (which is UB)

pub unsafe fn as_raw_unchecked(&self) -> *mut T[src]

Converts the relative pointer into a normal raw pointer

Safety

You must ensure that the relative pointer was successfully set 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]

Converts the relative pointer into a normal raw pointer

Safety

Same as RelPtr::as_raw

pub unsafe fn as_non_null_unchecked(&self) -> NonNull<T>[src]

Converts the relative pointer into a normal raw pointer

Safety

Same as RelPtr::as_raw_unchecked

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]

Gets a reference from the relative pointer

Safety

Same as RelPtr::as_raw_unchecked

pub unsafe fn as_mut_unchecked(&mut self) -> &mut T[src]

Gets a mutable reference from the relative pointer

Safety

Same as RelPtr::as_raw_unchecked

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]

#[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_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

impl<T, I = isize> !Send for RelPtr<T, I>

impl<T, I = isize> !Sync for RelPtr<T, I>

Blanket Implementations

impl<T> MetaData for T[src]

type Data = ()

the type of meta data a type carries

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]