#[repr(transparent)]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
sourceimpl<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
sourceimpl<F: ?Sized, W: ArchiveWith<F>> Archive for With<F, W>
impl<F: ?Sized, W: ArchiveWith<F>> Archive for With<F, W>
sourceimpl<'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::Archived]>
type Archived = ArchivedBox<[T::Archived]>
The archived type of a With<F, Self>
.
type Resolver = BoxResolver<MetadataResolver<[T]>>
type Resolver = BoxResolver<MetadataResolver<[T]>>
The resolver of a With<F, Self>
.
sourceimpl<F, W, T, D> Deserialize<With<T, W>, D> for F where
F: ?Sized,
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for F where
F: ?Sized,
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourcefn 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.
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<'a, T, S> SerializeWith<With<&'a [T], RefAsBox>, S> for CopyOptimize where
T: Serialize<S>,
S: Serializer,
impl<'a, T, S> SerializeWith<With<&'a [T], RefAsBox>, S> for CopyOptimize where
T: Serialize<S>,
S: Serializer,
Auto Trait Implementations
impl<F: ?Sized, W> RefUnwindSafe for With<F, W> where
F: RefUnwindSafe,
W: RefUnwindSafe,
impl<F: ?Sized, W> Send for With<F, W> where
F: Send,
W: Send,
impl<F: ?Sized, W> Sync for With<F, W> where
F: Sync,
W: Sync,
impl<F: ?Sized, W> Unpin for With<F, W> where
F: Unpin,
W: Unpin,
impl<F: ?Sized, W> UnwindSafe for With<F, W> where
F: UnwindSafe,
W: UnwindSafe,
Blanket Implementations
sourceimpl<T> ArchivePointee for T
impl<T> ArchivePointee for T
type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
sourcefn pointer_metadata(_: &Self::ArchivedMetadata) -> <Self as Pointee>::Metadata
fn pointer_metadata(_: &Self::ArchivedMetadata) -> <Self as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
sourceimpl<T> ArchiveUnsized for T where
T: Archive,
impl<T> ArchiveUnsized for T where
T: Archive,
type Archived = T::Archived
type Archived = T::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
sourceunsafe fn resolve_metadata(
&self,
_: usize,
_: Self::MetadataResolver,
_: *mut ArchivedMetadata<Self>
)
unsafe fn resolve_metadata(
&self,
_: usize,
_: Self::MetadataResolver,
_: *mut ArchivedMetadata<Self>
)
Creates the archived version of the metadata for this value at the given position and writes it to the given output. Read more
sourceunsafe 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 more
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more