Struct rkyv::boxed::BoxResolver
source · pub struct BoxResolver<M> { /* private fields */ }
Expand description
The resolver for Box
.
Implementations§
source§impl<M> BoxResolver<M>
impl<M> BoxResolver<M>
sourcepub unsafe fn from_raw_parts(pos: usize, metadata_resolver: M) -> Self
pub unsafe fn from_raw_parts(pos: usize, metadata_resolver: M) -> Self
Create a a new BoxResolver<M>
from raw parts. Note that M
here is not the same
T
which should be serialized/contained in the resulting ArchivedBox<T>
, and is rather
a type that can be used to resolve any needed ArchivePointee::ArchivedMetadata
for the serialized pointed-to value.
In most cases, you won’t need to create a BoxResolver
yourself and can instead obtain it through
ArchivedBox::serialize_from_ref
or ArchivedBox::serialize_copy_from_slice
.
§Safety
Technically no unsafety can happen directly from calling this function, however, passing this as a resolver to
ArchivedBox
’s resolving functions absolutely can. In general this should be treated as a semi-private type, as
constructing a valid resolver is quite fraught. Please make sure you understand what the implications are before doing it.
-
pos
: You must ensure that you serialized and resolved (i.e.Serializer::serialize_value
) aT
which will be pointed to by the finalArchivedBox<T>
that this resolver will help resolve at the givenpos
within the archive. -
metadata_resolver
: You must also ensure that the givenmetadata_resolver
can be used to successfully produce valid<T as ArchivePointee>::ArchivedMetadata
for that serializedT
. This means it must either be:- The necessary
<T as ArchivePointee>::ArchivedMetadata
itself, in which case you may use the createdBoxResolver<<T as ArchivePointee>::ArchivedMetadata>
as a resolver inArchivedBox::resolve_from_raw_parts
- An
ArchiveUnsized::MetadataResolver
obtained from somevalue: &U
whereU: ArchiveUnsized<Archived = T>
, in which case you must pass that samevalue: &U
intoArchivedBox::resolve_from_ref
along with thisBoxResolver
.
- The necessary