Skip to main content

RelPtr

Struct RelPtr 

Source
pub struct RelPtr<T: ArchivePointee + ?Sized, O> { /* private fields */ }
Expand description

A pointer which resolves to relative to its position in memory.

This is a strongly-typed version of RawRelPtr.

See Archive for an example of creating one.

Implementations§

Source§

impl<T, O: Offset> RelPtr<T, O>

Source

pub fn try_emplace<E: Source>(to: usize, out: Place<Self>) -> Result<(), E>

Attempts to create a relative pointer from one position to another.

Source

pub fn emplace(to: usize, out: Place<Self>)

Creates a relative pointer from one position to another.

§Panics
  • If the offset between from and to does not fit in an isize
  • If the offset between from and to exceeds the offset storage
Source§

impl<T: ArchivePointee + ?Sized, O: Offset> RelPtr<T, O>

Source

pub fn try_emplace_invalid<E: Source>(out: Place<Self>) -> Result<(), E>

Attempts to create an invalid relative pointer with default metadata.

Source

pub fn emplace_invalid(out: Place<Self>)

Creates an invalid relative pointer with default metadata.

§Panics
  • If an offset of 1 does not fit in an isize
  • If an offset of 1 exceeds the offset storage
Source

pub fn try_emplace_unsized<E: Source>( to: usize, metadata: T::ArchivedMetadata, out: Place<Self>, ) -> Result<(), E>

Attempts to create a relative pointer from one position to another.

Source

pub fn emplace_unsized( to: usize, metadata: T::ArchivedMetadata, out: Place<Self>, )

Creates a relative pointer from one position to another.

§Panics
  • If the offset between from and to does not fit in an isize
  • If the offset between from and to exceeds the offset storage
Source

pub fn base_raw(this: *mut Self) -> *mut u8

Gets the base pointer for the pointed-to relative pointer.

Source

pub unsafe fn offset_raw(this: *mut Self) -> isize

Gets the offset of the pointed-to relative pointer from its base.

§Safety

this must be non-null, properly-aligned, and point to a valid RelPtr.

Source

pub unsafe fn as_ptr_raw(this: *mut Self) -> *mut T

Calculates the memory address being pointed to by the pointed-to relative pointer.

§Safety
  • this must be non-null, properly-aligned, and point to a valid RelPtr.
  • The offset of this relative pointer, when added to its base, must be located in the same allocated object as it.
Source

pub unsafe fn as_ptr_wrapping_raw(this: *mut Self) -> *mut T

Calculates the memory address being pointed to by the pointed-to relative pointer using wrapping methods.

This method is a safer but potentially slower version of as_ptr_raw.

§Safety

this must be non-null, properly-aligned, and point to a valid RelPtr.

Source

pub unsafe fn is_invalid_raw(this: *mut Self) -> bool

Gets whether the offset of the pointed-to relative pointer is invalid.

§Safety

this must be non-null, properly-aligned, and point to a valid RawRelPtr.

Source

pub fn base(&self) -> *const u8

Gets the base pointer for the relative pointer.

Source

pub fn base_mut(this: Seal<'_, Self>) -> *mut u8

Gets the mutable base pointer for this relative pointer.

Source

pub fn offset(&self) -> isize

Gets the offset of the relative pointer from its base.

Source

pub fn is_invalid(&self) -> bool

Gets whether the offset of the relative pointer is 0.

Source

pub fn metadata(&self) -> &T::ArchivedMetadata

Gets the metadata of the relative pointer.

Source

pub unsafe fn as_ptr(&self) -> *const T

Calculates the memory address being pointed to by this relative pointer.

§Safety

The offset of this relative pointer, when added to its base, must be located in the same allocated object as it.

Source

pub unsafe fn as_mut_ptr(this: Seal<'_, Self>) -> *mut T

Calculates the mutable memory address being pointed to by this relative pointer.

§Safety

The offset of this relative pointer, when added to its base, must be located in the same allocated object as it.

Source

pub fn as_ptr_wrapping(&self) -> *const T

Calculates the memory address being pointed to by this relative pointer using wrapping methods.

This method is a safer but potentially slower version of as_ptr.

Source

pub fn as_mut_ptr_wrapping(this: Seal<'_, Self>) -> *mut T

Calculates the mutable memory address being pointed to by this relative pointer using wrapping methods.

This method is a safer but potentially slower version of as_ptr.

Trait Implementations§

Source§

impl<T: ArchivePointee + ?Sized, O, __C: Fallible + ?Sized> CheckBytes<__C> for RelPtr<T, O>
where <__C as Fallible>::Error: Trace, RawRelPtr<O>: CheckBytes<__C>, T::ArchivedMetadata: CheckBytes<__C>, PhantomData<T>: CheckBytes<__C>,

Source§

unsafe fn check_bytes( value: *const Self, context: &mut __C, ) -> Result<(), <__C as Fallible>::Error>

Checks whether the given pointer points to a valid value within the given context. Read more
Source§

impl<T: ArchivePointee + ?Sized, O: Debug> Debug for RelPtr<T, O>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: ArchivePointee + ?Sized, O: Offset> Pointer for RelPtr<T, O>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: ArchivePointee + ?Sized, O> Portable for RelPtr<T, O>

Auto Trait Implementations§

§

impl<T, O> Freeze for RelPtr<T, O>

§

impl<T, O> RefUnwindSafe for RelPtr<T, O>

§

impl<T, O> Send for RelPtr<T, O>
where O: Send, T: Send + ?Sized,

§

impl<T, O> Sync for RelPtr<T, O>
where O: Sync, T: Sync + ?Sized,

§

impl<T, O> !Unpin for RelPtr<T, O>

§

impl<T, O> !UnsafeUnpin for RelPtr<T, O>

§

impl<T, O> UnwindSafe for RelPtr<T, O>

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
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.