pub struct AsVec;
Expand description
A wrapper that serializes associative containers as a Vec
of key-value pairs.
This provides faster serialization for containers like HashMap
and BTreeMap
by serializing
the key-value pairs directly instead of building a data structure in the buffer.
§Example
use std::collections::HashMap;
use rkyv::{Archive, with::AsVec};
#[derive(Archive)]
struct Example {
#[with(AsVec)]
values: HashMap<String, u32>,
}
Trait Implementations§
source§impl<K: Archive, V: Archive> ArchiveWith<BTreeMap<K, V>> for AsVec
impl<K: Archive, V: Archive> ArchiveWith<BTreeMap<K, V>> for AsVec
source§impl<T: Archive> ArchiveWith<BTreeSet<T>> for AsVec
impl<T: Archive> ArchiveWith<BTreeSet<T>> for AsVec
§type Archived = ArchivedVec<<T as Archive>::Archived>
type Archived = ArchivedVec<<T as Archive>::Archived>
The archived type of a
With<F, Self>
.§type Resolver = VecResolver
type Resolver = VecResolver
The resolver of a
With<F, Self>
.source§impl<K: Archive, V: Archive> ArchiveWith<HashMap<K, V>> for AsVec
impl<K: Archive, V: Archive> ArchiveWith<HashMap<K, V>> for AsVec
source§impl<T: Archive> ArchiveWith<HashSet<T>> for AsVec
impl<T: Archive> ArchiveWith<HashSet<T>> for AsVec
§type Archived = ArchivedVec<<T as Archive>::Archived>
type Archived = ArchivedVec<<T as Archive>::Archived>
The archived type of a
With<F, Self>
.§type Resolver = VecResolver
type Resolver = VecResolver
The resolver of a
With<F, Self>
.source§impl<T, D> DeserializeWith<ArchivedVec<<T as Archive>::Archived>, BTreeSet<T>, D> for AsVec
impl<T, D> DeserializeWith<ArchivedVec<<T as Archive>::Archived>, BTreeSet<T>, D> for AsVec
source§fn deserialize_with(
field: &ArchivedVec<T::Archived>,
deserializer: &mut D
) -> Result<BTreeSet<T>, D::Error>
fn deserialize_with( field: &ArchivedVec<T::Archived>, deserializer: &mut D ) -> Result<BTreeSet<T>, D::Error>
Deserializes the field type
F
using the given deserializer.source§impl<T, D> DeserializeWith<ArchivedVec<<T as Archive>::Archived>, HashSet<T>, D> for AsVec
impl<T, D> DeserializeWith<ArchivedVec<<T as Archive>::Archived>, HashSet<T>, D> for AsVec
source§fn deserialize_with(
field: &ArchivedVec<T::Archived>,
deserializer: &mut D
) -> Result<HashSet<T>, D::Error>
fn deserialize_with( field: &ArchivedVec<T::Archived>, deserializer: &mut D ) -> Result<HashSet<T>, D::Error>
Deserializes the field type
F
using the given deserializer.source§impl<K, V, D> DeserializeWith<ArchivedVec<Entry<<K as Archive>::Archived, <V as Archive>::Archived>>, BTreeMap<K, V>, D> for AsVecwhere
K: Archive + Ord,
V: Archive,
K::Archived: Deserialize<K, D>,
V::Archived: Deserialize<V, D>,
D: Fallible + ?Sized,
impl<K, V, D> DeserializeWith<ArchivedVec<Entry<<K as Archive>::Archived, <V as Archive>::Archived>>, BTreeMap<K, V>, D> for AsVecwhere
K: Archive + Ord,
V: Archive,
K::Archived: Deserialize<K, D>,
V::Archived: Deserialize<V, D>,
D: Fallible + ?Sized,
source§impl<K, V, D> DeserializeWith<ArchivedVec<Entry<<K as Archive>::Archived, <V as Archive>::Archived>>, HashMap<K, V>, D> for AsVecwhere
K: Archive + Hash + Eq,
V: Archive,
K::Archived: Deserialize<K, D>,
V::Archived: Deserialize<V, D>,
D: Fallible + ?Sized,
impl<K, V, D> DeserializeWith<ArchivedVec<Entry<<K as Archive>::Archived, <V as Archive>::Archived>>, HashMap<K, V>, D> for AsVecwhere
K: Archive + Hash + Eq,
V: Archive,
K::Archived: Deserialize<K, D>,
V::Archived: Deserialize<V, D>,
D: Fallible + ?Sized,
source§impl<K, V, S> SerializeWith<BTreeMap<K, V>, S> for AsVec
impl<K, V, S> SerializeWith<BTreeMap<K, V>, S> for AsVec
source§impl<T, S> SerializeWith<BTreeSet<T>, S> for AsVec
impl<T, S> SerializeWith<BTreeSet<T>, S> for AsVec
source§impl<K, V, S> SerializeWith<HashMap<K, V>, S> for AsVec
impl<K, V, S> SerializeWith<HashMap<K, V>, S> for AsVec
source§impl<T, S> SerializeWith<HashSet<T>, S> for AsVec
impl<T, S> SerializeWith<HashSet<T>, S> for AsVec
Auto Trait Implementations§
impl RefUnwindSafe for AsVec
impl Send for AsVec
impl Sync for AsVec
impl Unpin for AsVec
impl UnwindSafe for AsVec
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> 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
source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.