#[repr(transparent)]pub struct RawRelPtr<O> { /* private fields */ }
Expand description
An untyped pointer which resolves relative to its position in memory.
This is the most fundamental building block in rkyv. It allows the construction and use of pointers that can be safely relocated as long as the source and target are moved together. This is what allows memory to be moved from disk into memory and accessed without decoding.
Regular pointers are absolute, meaning that the pointee can be moved without invalidating the pointer. However, the target cannot be moved or the pointer is invalidated.
Relative pointers are relative, meaning that the pointee can be moved with the target without invalidating the pointer. However, if either the pointee or the target move independently, the pointer will be invalidated.
Implementations
sourceimpl<O: Offset> RawRelPtr<O>
impl<O: Offset> RawRelPtr<O>
sourcepub unsafe fn try_emplace(
from: usize,
to: usize,
out: *mut Self
) -> Result<(), OffsetError>
pub unsafe fn try_emplace(
from: usize,
to: usize,
out: *mut Self
) -> Result<(), OffsetError>
Attempts to create a new RawRelPtr
in-place between the given from
and to
positions.
Safety
out
must be located at positionfrom
to
must be a position within the archive
sourcepub unsafe fn emplace(from: usize, to: usize, out: *mut Self)
pub unsafe fn emplace(from: usize, to: usize, out: *mut Self)
Creates a new RawRelPtr
in-place between the given from
and to
positions.
Safety
out
must be located at positionfrom
to
must be a position within the archive- The offset between
from
andto
must fit in anisize
and not exceed the offset storage
sourcepub fn as_ptr(&self) -> *const ()
pub fn as_ptr(&self) -> *const ()
Calculates the memory address being pointed to by this relative pointer.
sourcepub fn as_mut_ptr(&mut self) -> *mut ()
pub fn as_mut_ptr(&mut self) -> *mut ()
Returns an unsafe mutable pointer to the memory address being pointed to by this relative pointer.
Trait Implementations
Auto Trait Implementations
impl<O> RefUnwindSafe for RawRelPtr<O> where
O: RefUnwindSafe,
impl<O> Send for RawRelPtr<O> where
O: Send,
impl<O> Sync for RawRelPtr<O> where
O: Sync,
impl<O> !Unpin for RawRelPtr<O>
impl<O> UnwindSafe for RawRelPtr<O> where
O: UnwindSafe,
Blanket Implementations
sourceimpl<T> ArchivePointee for T
impl<T> ArchivePointee for T
type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
sourcefn pointer_metadata(_: &Self::ArchivedMetadata) -> <Self as Pointee>::Metadata
fn pointer_metadata(_: &Self::ArchivedMetadata) -> <Self as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more