pub struct RelPtr<T: ArchivePointee + ?Sized, O> { /* private fields */ }
Expand description
Implementations§
source§impl<T, O: Offset> RelPtr<T, O>
impl<T, O: Offset> RelPtr<T, 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 relative pointer from one position to another.
§Safety
from
must be the position ofout
within the archiveto
must be the position of some validT
source§impl<T: ArchivePointee + ?Sized, O: Offset> RelPtr<T, O>where
T::ArchivedMetadata: Default,
impl<T: ArchivePointee + ?Sized, O: Offset> RelPtr<T, O>where
T::ArchivedMetadata: Default,
sourcepub unsafe fn try_emplace_null(
pos: usize,
out: *mut Self,
) -> Result<(), OffsetError>
pub unsafe fn try_emplace_null( pos: usize, out: *mut Self, ) -> Result<(), OffsetError>
Attempts to create a null relative pointer with default metadata.
§Safety
pos
must be the position of out
within the archive.
source§impl<T: ArchivePointee + ?Sized, O: Offset> RelPtr<T, O>
impl<T: ArchivePointee + ?Sized, O: Offset> RelPtr<T, O>
sourcepub unsafe fn try_resolve_emplace<U: ArchiveUnsized<Archived = T> + ?Sized>(
from: usize,
to: usize,
value: &U,
metadata_resolver: U::MetadataResolver,
out: *mut Self,
) -> Result<(), OffsetError>
pub unsafe fn try_resolve_emplace<U: ArchiveUnsized<Archived = T> + ?Sized>( from: usize, to: usize, value: &U, metadata_resolver: U::MetadataResolver, out: *mut Self, ) -> Result<(), OffsetError>
Attempts to create a relative pointer from one position to another.
§Safety
from
must be the position ofout
within the archiveto
must be the position of some validT
value
must be the value being serializedmetadata_resolver
must be the result of serializing the metadata ofvalue
sourcepub unsafe fn resolve_emplace<U: ArchiveUnsized<Archived = T> + ?Sized>(
from: usize,
to: usize,
value: &U,
metadata_resolver: U::MetadataResolver,
out: *mut Self,
)
pub unsafe fn resolve_emplace<U: ArchiveUnsized<Archived = T> + ?Sized>( from: usize, to: usize, value: &U, metadata_resolver: U::MetadataResolver, out: *mut Self, )
Creates a relative pointer from one position to another.
§Panics
- The offset between
from
andto
does not fit in anisize
- The offset between
from
andto
exceeds the offset storage
§Safety
from
must be the position ofout
within the archiveto
must be the position of some validT
value
must be the value being serializedmetadata_resolver
must be the result of serializing the metadata ofvalue
sourcepub unsafe fn try_resolve_emplace_from_raw_parts(
from: usize,
to: usize,
archived_metadata: <T as ArchivePointee>::ArchivedMetadata,
out: *mut Self,
) -> Result<(), OffsetError>
pub unsafe fn try_resolve_emplace_from_raw_parts( from: usize, to: usize, archived_metadata: <T as ArchivePointee>::ArchivedMetadata, out: *mut Self, ) -> Result<(), OffsetError>
Attempts to create a relative pointer from one position to another given raw pointer metadata.
This does the same thing as RelPtr::try_resolve_emplace
but you must supply
the <T as ArchivePointee>::ArchivedMetadata
yourself directly rather than through an implementation of ArchiveUnsized
on some
value.
§Safety
from
must be the position ofout
within the archiveto
must be the position of some validT
value
must be the value being serializedarchived_metadata
must produce valid metadata for the pointee of the resultingRelPtr
(the thing being pointed at) when<T as ArchivePointee>::pointer_metadata(archived_metadata)
is called.
sourcepub unsafe fn resolve_emplace_from_raw_parts(
from: usize,
to: usize,
archived_metadata: <T as ArchivePointee>::ArchivedMetadata,
out: *mut Self,
)
pub unsafe fn resolve_emplace_from_raw_parts( from: usize, to: usize, archived_metadata: <T as ArchivePointee>::ArchivedMetadata, out: *mut Self, )
Creates a relative pointer from one position to another given raw pointer metadata.
This does the same thing as RelPtr::resolve_emplace
but you must supply
the <T as ArchivePointee>::ArchivedMetadata
yourself directly rather than through an implementation of ArchiveUnsized
on some
value.
§Panics
- The offset between
from
andto
does not fit in anisize
- The offset between
from
andto
exceeds the offset storage
§Safety
from
must be the position ofout
within the archiveto
must be the position of some validT
value
must be the value being serializedarchived_metadata
must produce valid metadata for the pointee of the resultingRelPtr
(the thing being pointed at) when<T as ArchivePointee>::pointer_metadata(archived_metadata)
is called.
sourcepub fn metadata(&self) -> &T::ArchivedMetadata
pub fn metadata(&self) -> &T::ArchivedMetadata
Gets the metadata of the relative pointer.
sourcepub fn as_ptr(&self) -> *const T
pub fn as_ptr(&self) -> *const T
Calculates the memory address being pointed to by this relative pointer.
sourcepub fn as_mut_ptr(&mut self) -> *mut T
pub fn as_mut_ptr(&mut self) -> *mut T
Returns an unsafe mutable pointer to the memory address being pointed to by this relative pointer.