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) aTwhich will be pointed to by the finalArchivedBox<T>that this resolver will help resolve at the givenposwithin the archive. -
metadata_resolver: You must also ensure that the givenmetadata_resolvercan be used to successfully produce valid<T as ArchivePointee>::ArchivedMetadatafor that serializedT. This means it must either be:- The necessary
<T as ArchivePointee>::ArchivedMetadataitself, in which case you may use the createdBoxResolver<<T as ArchivePointee>::ArchivedMetadata>as a resolver inArchivedBox::resolve_from_raw_parts - An
ArchiveUnsized::MetadataResolverobtained from somevalue: &UwhereU: ArchiveUnsized<Archived = T>, in which case you must pass that samevalue: &UintoArchivedBox::resolve_from_refalong with thisBoxResolver.
- The necessary