Struct rkyv::with::CopyOptimize
source · [−]pub struct CopyOptimize;
Expand description
A wrapper that provides specialized, performant implementations of serialization and deserialization.
This wrapper can be used with containers like Vec
, but care must be taken to ensure that they
contain copy-safe types. Copy-safe types must be trivially copyable (have the same archived and
unarchived representations) and contain no padding bytes. In situations where copying
uninitialized bytes the output is acceptable, this wrapper may be used with containers of types
that contain padding bytes.
Safety
Using this wrapper with containers containing non-copy-safe types may result in undefined behavior.
Example
use rkyv::{Archive, with::CopyOptimize};
#[derive(Archive)]
struct Example {
#[with(CopyOptimize)]
bytes: Vec<u8>,
}
Trait Implementations
sourceimpl<T: Archive> ArchiveWith<Box<[T], Global>> for CopyOptimize
impl<T: Archive> ArchiveWith<Box<[T], Global>> 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<T: Archive> ArchiveWith<Vec<T, Global>> for CopyOptimize
impl<T: Archive> ArchiveWith<Vec<T, Global>> for CopyOptimize
type Archived = ArchivedVec<T::Archived>
type Archived = ArchivedVec<T::Archived>
The archived type of a With<F, Self>
.
type Resolver = VecResolver
type Resolver = VecResolver
The resolver of a With<F, Self>
.
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 Debug for CopyOptimize
impl Debug for CopyOptimize
sourceimpl<T, D> DeserializeWith<ArchivedBox<[<T as Archive>::Archived]>, Box<[T], Global>, D> for CopyOptimize where
T: Archive,
T::Archived: Deserialize<T, D>,
D: Fallible + ?Sized,
impl<T, D> DeserializeWith<ArchivedBox<[<T as Archive>::Archived]>, Box<[T], Global>, D> for CopyOptimize where
T: Archive,
T::Archived: Deserialize<T, D>,
D: Fallible + ?Sized,
sourceimpl<T, D> DeserializeWith<ArchivedVec<<T as Archive>::Archived>, Vec<T, Global>, D> for CopyOptimize where
T: Archive,
T::Archived: Deserialize<T, D>,
D: Fallible + ?Sized,
impl<T, D> DeserializeWith<ArchivedVec<<T as Archive>::Archived>, Vec<T, Global>, D> for CopyOptimize where
T: Archive,
T::Archived: Deserialize<T, D>,
D: Fallible + ?Sized,
sourcefn deserialize_with(
field: &ArchivedVec<T::Archived>,
_: &mut D
) -> Result<Vec<T>, D::Error>
fn deserialize_with(
field: &ArchivedVec<T::Archived>,
_: &mut D
) -> Result<Vec<T>, D::Error>
Deserializes the field type F
using the given deserializer.
sourceimpl<T, S> SerializeWith<Box<[T], Global>, S> for CopyOptimize where
T: Serialize<S>,
S: Serializer,
impl<T, S> SerializeWith<Box<[T], Global>, S> for CopyOptimize where
T: Serialize<S>,
S: Serializer,
sourceimpl<T, S> SerializeWith<Vec<T, Global>, S> for CopyOptimize where
T: Serialize<S>,
S: Serializer,
impl<T, S> SerializeWith<Vec<T, Global>, S> for CopyOptimize where
T: Serialize<S>,
S: Serializer,
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 RefUnwindSafe for CopyOptimize
impl Send for CopyOptimize
impl Sync for CopyOptimize
impl Unpin for CopyOptimize
impl UnwindSafe for CopyOptimize
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> 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