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
sourceimpl<K: Archive, V: Archive> ArchiveWith<BTreeMap<K, V>> for AsVec
impl<K: Archive, V: Archive> ArchiveWith<BTreeMap<K, V>> for AsVec
type Archived = ArchivedVec<Entry<K::Archived, V::Archived>>
type Archived = ArchivedVec<Entry<K::Archived, V::Archived>>
The archived type of a With<F, Self>
.
type Resolver = VecResolver
type Resolver = VecResolver
The resolver of a With<F, Self>
.
sourceimpl<T: Archive> ArchiveWith<BTreeSet<T>> for AsVec
impl<T: Archive> ArchiveWith<BTreeSet<T>> for AsVec
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<K: Archive, V: Archive> ArchiveWith<HashMap<K, V, RandomState>> for AsVec
impl<K: Archive, V: Archive> ArchiveWith<HashMap<K, V, RandomState>> for AsVec
type Archived = ArchivedVec<Entry<K::Archived, V::Archived>>
type Archived = ArchivedVec<Entry<K::Archived, V::Archived>>
The archived type of a With<F, Self>
.
type Resolver = VecResolver
type Resolver = VecResolver
The resolver of a With<F, Self>
.
sourceimpl<T: Archive> ArchiveWith<HashSet<T, RandomState>> for AsVec
impl<T: Archive> ArchiveWith<HashSet<T, RandomState>> for AsVec
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<T, D> DeserializeWith<ArchivedVec<<T as Archive>::Archived>, BTreeSet<T>, D> for AsVec where
T: Archive + Ord,
T::Archived: Deserialize<T, D>,
D: Fallible + ?Sized,
impl<T, D> DeserializeWith<ArchivedVec<<T as Archive>::Archived>, BTreeSet<T>, D> for AsVec where
T: Archive + Ord,
T::Archived: Deserialize<T, D>,
D: Fallible + ?Sized,
sourcefn 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.
sourceimpl<T, D> DeserializeWith<ArchivedVec<<T as Archive>::Archived>, HashSet<T, RandomState>, D> for AsVec where
T: Archive + Hash + Eq,
T::Archived: Deserialize<T, D>,
D: Fallible + ?Sized,
impl<T, D> DeserializeWith<ArchivedVec<<T as Archive>::Archived>, HashSet<T, RandomState>, D> for AsVec where
T: Archive + Hash + Eq,
T::Archived: Deserialize<T, D>,
D: Fallible + ?Sized,
sourcefn 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.
sourceimpl<K, V, D> DeserializeWith<ArchivedVec<Entry<<K as Archive>::Archived, <V as Archive>::Archived>>, BTreeMap<K, V>, D> for AsVec where
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 AsVec where
K: Archive + Ord,
V: Archive,
K::Archived: Deserialize<K, D>,
V::Archived: Deserialize<V, D>,
D: Fallible + ?Sized,
sourcefn deserialize_with(
field: &ArchivedVec<Entry<K::Archived, V::Archived>>,
deserializer: &mut D
) -> Result<BTreeMap<K, V>, D::Error>
fn deserialize_with(
field: &ArchivedVec<Entry<K::Archived, V::Archived>>,
deserializer: &mut D
) -> Result<BTreeMap<K, V>, D::Error>
Deserializes the field type F
using the given deserializer.
sourceimpl<K, V, D> DeserializeWith<ArchivedVec<Entry<<K as Archive>::Archived, <V as Archive>::Archived>>, HashMap<K, V, RandomState>, D> for AsVec where
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, RandomState>, D> for AsVec where
K: Archive + Hash + Eq,
V: Archive,
K::Archived: Deserialize<K, D>,
V::Archived: Deserialize<V, D>,
D: Fallible + ?Sized,
sourcefn deserialize_with(
field: &ArchivedVec<Entry<K::Archived, V::Archived>>,
deserializer: &mut D
) -> Result<HashMap<K, V>, D::Error>
fn deserialize_with(
field: &ArchivedVec<Entry<K::Archived, V::Archived>>,
deserializer: &mut D
) -> Result<HashMap<K, V>, D::Error>
Deserializes the field type F
using the given deserializer.
sourceimpl<K, V, S> SerializeWith<BTreeMap<K, V>, S> for AsVec where
K: Serialize<S>,
V: Serialize<S>,
S: ScratchSpace + Serializer + ?Sized,
impl<K, V, S> SerializeWith<BTreeMap<K, V>, S> for AsVec where
K: Serialize<S>,
V: Serialize<S>,
S: ScratchSpace + Serializer + ?Sized,
sourceimpl<T, S> SerializeWith<BTreeSet<T>, S> for AsVec where
T: Serialize<S>,
S: ScratchSpace + Serializer + ?Sized,
impl<T, S> SerializeWith<BTreeSet<T>, S> for AsVec where
T: Serialize<S>,
S: ScratchSpace + Serializer + ?Sized,
sourceimpl<K, V, S> SerializeWith<HashMap<K, V, RandomState>, S> for AsVec where
K: Serialize<S>,
V: Serialize<S>,
S: ScratchSpace + Serializer + ?Sized,
impl<K, V, S> SerializeWith<HashMap<K, V, RandomState>, S> for AsVec where
K: Serialize<S>,
V: Serialize<S>,
S: ScratchSpace + Serializer + ?Sized,
sourceimpl<T, S> SerializeWith<HashSet<T, RandomState>, S> for AsVec where
T: Serialize<S>,
S: ScratchSpace + Serializer + ?Sized,
impl<T, S> SerializeWith<HashSet<T, RandomState>, S> for AsVec where
T: Serialize<S>,
S: ScratchSpace + Serializer + ?Sized,
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
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