[go: up one dir, main page]

Struct rkyv::with::AsVec

source ·
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::{with::AsVec, Archive};

#[derive(Archive)]
struct Example {
    #[rkyv(with = AsVec)]
    values: HashMap<String, u32>,
}

Trait Implementations§

source§

impl<const A: usize> ArchiveWith<AlignedVec<A>> for AsVec

Available on crate feature alloc only.
source§

type Archived = ArchivedVec<u8>

The archived type of Self with F.
source§

type Resolver = VecResolver

The resolver of a Self with F.
source§

fn resolve_with( field: &AlignedVec<A>, resolver: Self::Resolver, out: Place<Self::Archived>, )

Resolves the archived type using a reference to the field type F.
source§

impl<K: Archive, V: Archive> ArchiveWith<BTreeMap<K, V>> for AsVec

Available on crate feature alloc only.
source§

type Archived = ArchivedVec<Entry<<K as Archive>::Archived, <V as Archive>::Archived>>

The archived type of Self with F.
source§

type Resolver = VecResolver

The resolver of a Self with F.
source§

fn resolve_with( field: &BTreeMap<K, V>, resolver: Self::Resolver, out: Place<Self::Archived>, )

Resolves the archived type using a reference to the field type F.
source§

impl<T: Archive> ArchiveWith<BTreeSet<T>> for AsVec

Available on crate feature alloc only.
source§

type Archived = ArchivedVec<<T as Archive>::Archived>

The archived type of Self with F.
source§

type Resolver = VecResolver

The resolver of a Self with F.
source§

fn resolve_with( field: &BTreeSet<T>, resolver: Self::Resolver, out: Place<Self::Archived>, )

Resolves the archived type using a reference to the field type F.
source§

impl<K: Archive, V: Archive, H> ArchiveWith<HashMap<K, V, H>> for AsVec

Available on crate feature std only.
source§

type Archived = ArchivedVec<Entry<<K as Archive>::Archived, <V as Archive>::Archived>>

The archived type of Self with F.
source§

type Resolver = VecResolver

The resolver of a Self with F.
source§

fn resolve_with( field: &HashMap<K, V, H>, resolver: Self::Resolver, out: Place<Self::Archived>, )

Resolves the archived type using a reference to the field type F.
source§

impl<T: Archive, H> ArchiveWith<HashSet<T, H>> for AsVec

Available on crate feature std only.
source§

type Archived = ArchivedVec<<T as Archive>::Archived>

The archived type of Self with F.
source§

type Resolver = VecResolver

The resolver of a Self with F.
source§

fn resolve_with( field: &HashSet<T, H>, resolver: Self::Resolver, out: Place<Self::Archived>, )

Resolves the archived type using a reference to the field type F.
source§

impl Debug for AsVec

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

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,

Available on crate feature alloc only.
source§

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, H, D> DeserializeWith<ArchivedVec<<T as Archive>::Archived>, HashSet<T, H>, D> for AsVec
where T: Archive + Hash + Eq, T::Archived: Deserialize<T, D>, H: BuildHasher + Default, D: Fallible + ?Sized,

Available on crate feature std only.
source§

fn deserialize_with( field: &ArchivedVec<T::Archived>, deserializer: &mut D, ) -> Result<HashSet<T, H>, 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 AsVec
where K: Archive + Ord, V: Archive, K::Archived: Deserialize<K, D>, V::Archived: Deserialize<V, D>, D: Fallible + ?Sized,

Available on crate feature alloc only.
source§

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.
source§

impl<K, V, H, D> DeserializeWith<ArchivedVec<Entry<<K as Archive>::Archived, <V as Archive>::Archived>>, HashMap<K, V, H>, D> for AsVec
where K: Archive + Hash + Eq, V: Archive, K::Archived: Deserialize<K, D>, V::Archived: Deserialize<V, D>, H: BuildHasher + Default, D: Fallible + ?Sized,

Available on crate feature std only.
source§

fn deserialize_with( field: &ArchivedVec<Entry<K::Archived, V::Archived>>, deserializer: &mut D, ) -> Result<HashMap<K, V, H>, D::Error>

Deserializes the field type F using the given deserializer.
source§

impl<D, const A: usize> DeserializeWith<ArchivedVec<u8>, AlignedVec<A>, D> for AsVec
where D: Fallible + ?Sized,

Available on crate feature alloc only.
source§

fn deserialize_with( field: &ArchivedVec<u8>, _: &mut D, ) -> Result<AlignedVec<A>, D::Error>

Deserializes the field type F using the given deserializer.
source§

impl<S, const A: usize> SerializeWith<AlignedVec<A>, S> for AsVec
where S: Allocator + Fallible + Writer + ?Sized,

Available on crate feature alloc only.
source§

fn serialize_with( field: &AlignedVec<A>, serializer: &mut S, ) -> Result<Self::Resolver, S::Error>

Serializes the field type F using the given serializer.
source§

impl<K, V, S> SerializeWith<BTreeMap<K, V>, S> for AsVec
where K: Serialize<S>, V: Serialize<S>, S: Fallible + Allocator + Writer + ?Sized,

Available on crate feature alloc only.
source§

fn serialize_with( field: &BTreeMap<K, V>, serializer: &mut S, ) -> Result<Self::Resolver, S::Error>

Serializes the field type F using the given serializer.
source§

impl<T, S> SerializeWith<BTreeSet<T>, S> for AsVec
where T: Serialize<S>, S: Fallible + Allocator + Writer + ?Sized,

Available on crate feature alloc only.
source§

fn serialize_with( field: &BTreeSet<T>, serializer: &mut S, ) -> Result<Self::Resolver, S::Error>

Serializes the field type F using the given serializer.
source§

impl<K, V, H, S> SerializeWith<HashMap<K, V, H>, S> for AsVec
where K: Serialize<S>, V: Serialize<S>, S: Fallible + Allocator + Writer + ?Sized,

Available on crate feature std only.
source§

fn serialize_with( field: &HashMap<K, V, H>, serializer: &mut S, ) -> Result<Self::Resolver, S::Error>

Serializes the field type F using the given serializer.
source§

impl<T, H, S> SerializeWith<HashSet<T, H>, S> for AsVec
where T: Serialize<S>, S: Fallible + Allocator + Writer + ?Sized,

Available on crate feature std only.
source§

fn serialize_with( field: &HashSet<T, H>, serializer: &mut S, ) -> Result<Self::Resolver, S::Error>

Serializes the field type F using the given serializer.

Auto Trait Implementations§

§

impl Freeze for AsVec

§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> ArchivePointee for T

source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> LayoutRaw for T

source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
source§

impl<T> Pointee for T

source§

type Metadata = ()

The metadata type for pointers and references to this type.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.