Struct rkyv::RelPtr [−][src]
A pointer which resolves to relative to its position in memory.
See Archive
for an example of creating one.
Implementations
impl<T: ArchivePointee + ?Sized> RelPtr<T>
[src]
pub unsafe fn manual_check_bytes<'a, C: Fallible + ?Sized>(
value: *const RelPtr<T>,
context: &mut C
) -> Result<&'a Self, <T::ArchivedMetadata as CheckBytes<C>>::Error> where
T: CheckBytes<C>,
T::ArchivedMetadata: CheckBytes<C>,
[src]
value: *const RelPtr<T>,
context: &mut C
) -> Result<&'a Self, <T::ArchivedMetadata as CheckBytes<C>>::Error> where
T: CheckBytes<C>,
T::ArchivedMetadata: CheckBytes<C>,
Checks the bytes of the given relative pointer.
This is done rather than implementing CheckBytes
to force users to
manually write their CheckBytes
implementation since they need to also
provide the ownership model of their memory.
impl<T: ArchivePointee + ?Sized> RelPtr<T>
[src]
pub unsafe fn new(raw_ptr: RawRelPtr, metadata: T::ArchivedMetadata) -> Self
[src]
Creates a new relative pointer from the given raw pointer and metadata.
Safety
raw_ptr
must be a valid relative pointer in its final position and
must point to a valid value.
metadata
must be valid metadata for the pointed value.
pub unsafe fn resolve<U: ArchiveUnsized<Archived = T> + ?Sized>(
from: usize,
to: usize,
value: &U,
metadata_resolver: U::MetadataResolver
) -> Self
[src]
from: usize,
to: usize,
value: &U,
metadata_resolver: U::MetadataResolver
) -> Self
Creates a relative pointer from one position to another.
Safety
from
must be the position of the relative pointer and to
must be the
position of some valid memory.
pub fn base(&self) -> *const u8
[src]
Gets the base pointer for the relative pointer.
pub fn offset(&self) -> isize
[src]
Gets the offset of the relative pointer.
pub fn metadata(&self) -> &T::ArchivedMetadata
[src]
Gets the metadata of the relative pointer.
pub fn as_ptr(&self) -> *const T
[src]
Calculates the memory address being pointed to by this relative pointer.
pub fn as_mut_ptr(&mut self) -> *mut T
[src]
Returns an unsafe mutable pointer to the memory address being pointed to by this relative pointer.
Trait Implementations
impl<T: ArchivePointee + ?Sized> Debug for RelPtr<T> where
T::ArchivedMetadata: Debug,
[src]
T::ArchivedMetadata: Debug,
Auto Trait Implementations
impl<T: ?Sized> RefUnwindSafe for RelPtr<T> where
T: RefUnwindSafe,
<T as ArchivePointee>::ArchivedMetadata: RefUnwindSafe,
T: RefUnwindSafe,
<T as ArchivePointee>::ArchivedMetadata: RefUnwindSafe,
impl<T: ?Sized> Send for RelPtr<T> where
T: Send,
<T as ArchivePointee>::ArchivedMetadata: Send,
T: Send,
<T as ArchivePointee>::ArchivedMetadata: Send,
impl<T: ?Sized> Sync for RelPtr<T> where
T: Sync,
<T as ArchivePointee>::ArchivedMetadata: Sync,
T: Sync,
<T as ArchivePointee>::ArchivedMetadata: Sync,
impl<T> !Unpin for RelPtr<T>
impl<T: ?Sized> UnwindSafe for RelPtr<T> where
T: UnwindSafe,
<T as ArchivePointee>::ArchivedMetadata: UnwindSafe,
T: UnwindSafe,
<T as ArchivePointee>::ArchivedMetadata: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> ArchivePointee for T
[src]
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
pub fn pointer_metadata(
&<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
[src]
&<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointee for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,