Skip to main content

RelativePtr

Struct RelativePtr 

Source
pub struct RelativePtr<T> { /* private fields */ }
Expand description

A Relative Pointer to the block memory address, relative to the start of the matrix inside the process memory scope.

This RelativePointer is used to calculate the accurate address of the block its related to. Providing a way for independent process to localize the data inside their own mappings of the SHM segment.

It also receives a PhantomData to inform the compiler we safely own whatever generic type the caller has passed to this pointer.

Implementations§

Source§

impl<T> RelativePtr<T>

Source

pub fn new(offset: u32) -> Self

Creates a new relative pointer based on the provided offset

This initializes the pointer with the PhantomData ownership over the type we are passing the the parameter

§Params:

@offset: The offset value to be wrapped in the pointer.

§Returns:

A instance of Self.

Source

pub fn offset(&self) -> u32

Returns the offset value in the pointer

Source

pub unsafe fn resolve_header<'a>(&self, base_ptr: *const u8) -> &'a BlockHeader

Resolves the header based on the base_ptr of the current caller process.

This ensures that the pointer returned is actually mapped to the process local memory scope

§Params:

@base_ptr: The offset from the start of the SHM segment.

§Returns:

A life time speficied reference to the header of this block

Source

pub unsafe fn resolve_header_mut<'a>( &self, base_ptr: *const u8, ) -> &'a mut BlockHeader

Source

pub unsafe fn resolve<'a>(&self, base_ptr: *const u8) -> &'a T

Resolves the block scope based on the base_ptr of the current caller process.

This ensures that the pointer returned is actually mapped to the process local memory scope

§Params:

@base_ptr: The offset from the start of the SHM segment.

§Returns:

A life time specified reference to the block scope.

Source

pub unsafe fn resolve_mut<'a>(&self, base_ptr: *const u8) -> &'a mut T

Resolves the block scope based on the base_ptr of the current caller process.

This ensures that the pointer returned is actually mapped to the process local memory scope

§Params:

@base_ptr: The offset from the start of the SHM segment.

§Returns:

A life time specified mutable reference to the block scope.

Auto Trait Implementations§

§

impl<T> Freeze for RelativePtr<T>

§

impl<T> RefUnwindSafe for RelativePtr<T>
where T: RefUnwindSafe,

§

impl<T> Send for RelativePtr<T>
where T: Send,

§

impl<T> Sync for RelativePtr<T>
where T: Sync,

§

impl<T> Unpin for RelativePtr<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for RelativePtr<T>

§

impl<T> UnwindSafe for RelativePtr<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.