pub struct With<F: ?Sized, W> { /* private fields */ }
Expand description
A transparent wrapper for archived fields.
This is used by the #[with(...)]
attribute in the Archive
macro to
create transparent serialization wrappers. Those wrappers leverage ArchiveWith
to change
how the type is archived, serialized, and deserialized.
When a field is serialized, a reference to the field (i.e. &T
) can be cast to a reference to a
wrapping With
(i.e. With<T, Wrapper>
) and serialized instead. This is safe to do because
With
is a transparent wrapper and is shaped exactly the same as the underlying field.
§Example
use rkyv::{Archive, with::Inline};
#[derive(Archive)]
struct Example<'a> {
// This will archive as if it were With<&'a i32, Inline>. That will delegate the archival
// to the ArchiveWith implementation of Inline for &T.
#[with(Inline)]
a: &'a i32,
}
Implementations§
source§impl<F, W> With<F, W>
impl<F, W> With<F, W>
sourcepub fn into_inner(self) -> F
pub fn into_inner(self) -> F
Unwraps a With
into the underlying field.
Trait Implementations§
source§impl<F: ?Sized, W: ArchiveWith<F>> Archive for With<F, W>
impl<F: ?Sized, W: ArchiveWith<F>> Archive for With<F, W>
§type Archived = <W as ArchiveWith<F>>::Archived
type Archived = <W as ArchiveWith<F>>::Archived
The archived representation of this type. Read more
§type Resolver = <W as ArchiveWith<F>>::Resolver
type Resolver = <W as ArchiveWith<F>>::Resolver
The resolver for this type. It must contain all the additional information from serializing
needed to make the archived type from the normal type.
source§impl<'a, T: Archive> ArchiveWith<With<&'a [T], RefAsBox>> for CopyOptimize
impl<'a, T: Archive> ArchiveWith<With<&'a [T], RefAsBox>> for CopyOptimize
§type Archived = ArchivedBox<[<T as Archive>::Archived]>
type Archived = ArchivedBox<[<T as Archive>::Archived]>
The archived type of a
With<F, Self>
.§type Resolver = BoxResolver<<[T] as ArchiveUnsized>::MetadataResolver>
type Resolver = BoxResolver<<[T] as ArchiveUnsized>::MetadataResolver>
The resolver of a
With<F, Self>
.source§impl<D: Fallible + ?Sized> DeserializeWith<<With<AtomicI16, Atomic> as Archive>::Archived, AtomicI16, D> for Atomic
impl<D: Fallible + ?Sized> DeserializeWith<<With<AtomicI16, Atomic> as Archive>::Archived, AtomicI16, D> for Atomic
source§impl<D: Fallible + ?Sized> DeserializeWith<<With<AtomicI32, Atomic> as Archive>::Archived, AtomicI32, D> for Atomic
impl<D: Fallible + ?Sized> DeserializeWith<<With<AtomicI32, Atomic> as Archive>::Archived, AtomicI32, D> for Atomic
source§impl<D: Fallible + ?Sized> DeserializeWith<<With<AtomicI64, Atomic> as Archive>::Archived, AtomicI64, D> for Atomic
impl<D: Fallible + ?Sized> DeserializeWith<<With<AtomicI64, Atomic> as Archive>::Archived, AtomicI64, D> for Atomic
source§impl<D: Fallible + ?Sized> DeserializeWith<<With<AtomicIsize, Atomic> as Archive>::Archived, AtomicIsize, D> for Atomic
impl<D: Fallible + ?Sized> DeserializeWith<<With<AtomicIsize, Atomic> as Archive>::Archived, AtomicIsize, D> for Atomic
source§fn deserialize_with(
field: &Archived<With<AtomicIsize, Self>>,
_: &mut D,
) -> Result<AtomicIsize, D::Error>
fn deserialize_with( field: &Archived<With<AtomicIsize, Self>>, _: &mut D, ) -> Result<AtomicIsize, D::Error>
Deserializes the field type
F
using the given deserializer.source§impl<D: Fallible + ?Sized> DeserializeWith<<With<AtomicU16, Atomic> as Archive>::Archived, AtomicU16, D> for Atomic
impl<D: Fallible + ?Sized> DeserializeWith<<With<AtomicU16, Atomic> as Archive>::Archived, AtomicU16, D> for Atomic
source§impl<D: Fallible + ?Sized> DeserializeWith<<With<AtomicU32, Atomic> as Archive>::Archived, AtomicU32, D> for Atomic
impl<D: Fallible + ?Sized> DeserializeWith<<With<AtomicU32, Atomic> as Archive>::Archived, AtomicU32, D> for Atomic
source§impl<D: Fallible + ?Sized> DeserializeWith<<With<AtomicU64, Atomic> as Archive>::Archived, AtomicU64, D> for Atomic
impl<D: Fallible + ?Sized> DeserializeWith<<With<AtomicU64, Atomic> as Archive>::Archived, AtomicU64, D> for Atomic
source§impl<'a, T, S> SerializeWith<With<&'a [T], RefAsBox>, S> for CopyOptimize
impl<'a, T, S> SerializeWith<With<&'a [T], RefAsBox>, S> for CopyOptimize
Auto Trait Implementations§
impl<F, W> Freeze for With<F, W>
impl<F, W> RefUnwindSafe for With<F, W>
impl<F, W> Send for With<F, W>
impl<F, W> Sync for With<F, W>
impl<F, W> Unpin for With<F, W>
impl<F, W> UnwindSafe for With<F, W>
Blanket Implementations§
source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
The archived counterpart of this type. Unlike
Archive
, it may be unsized. Read more§type MetadataResolver = ()
type MetadataResolver = ()
The resolver for the metadata of this type. Read more
source§unsafe fn resolve_metadata(
&self,
_: usize,
_: <T as ArchiveUnsized>::MetadataResolver,
_: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata,
)
unsafe fn resolve_metadata( &self, _: usize, _: <T as ArchiveUnsized>::MetadataResolver, _: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata, )
Creates the archived version of the metadata for this value at the given position and writes
it to the given output. Read more
source§unsafe fn resolve_unsized(
&self,
from: usize,
to: usize,
resolver: Self::MetadataResolver,
out: *mut RelPtr<Self::Archived>,
)
unsafe fn resolve_unsized( &self, from: usize, to: usize, resolver: Self::MetadataResolver, out: *mut RelPtr<Self::Archived>, )
Resolves a relative pointer to this value with the given
from
and to
and writes it to
the given output. Read moresource§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more