Struct wasmer_types::entity::PrimaryMap [−][src]
pub struct PrimaryMap<K, V> where
K: EntityRef, { /* fields omitted */ }
Expand description
A primary mapping K -> V
allocating dense entity references.
The PrimaryMap
data structure uses the dense index space to implement a map with a vector.
A primary map contains the main definition of an entity, and it can be used to allocate new
entity references with the push
method.
There should only be a single PrimaryMap
instance for a given EntityRef
type, otherwise
conflicting references will be created. Using unknown keys for indexing will cause a panic.
Note that PrimaryMap
doesn’t implement Deref
or DerefMut
, which would allow
&PrimaryMap<K, V>
to convert to &[V]
. One of the main advantages of PrimaryMap
is
that it only allows indexing with the distinct EntityRef
key type, so converting to a
plain slice would make it easier to use incorrectly. To make a slice of a PrimaryMap
, use
into_boxed_slice
.
Implementations
Create a new empty map with the given capacity.
Get the element at k
if it exists, mutable version.
Iterate over all the keys in this map.
Iterate over all the values in this map.
Iterate over all the values in this map, mutable edition.
Iterate over all the keys and values in this map.
Iterate over all the keys and values in this map, mutable edition.
Append v
to the mapping, assigning a new key which is returned.
Reserves capacity for at least additional
more elements to be inserted.
Reserves the minimum capacity for exactly additional
more elements to be inserted.
Shrinks the capacity of the PrimaryMap
as much as possible.
Consumes this PrimaryMap
and produces a BoxedSlice
.
Trait Implementations
impl<K, V> Archive for PrimaryMap<K, V> where
K: EntityRef,
Vec<V>: Archive,
PhantomData<K>: Archive,
[src]
impl<K, V> Archive for PrimaryMap<K, V> where
K: EntityRef,
Vec<V>: Archive,
PhantomData<K>: Archive,
[src]Returns the “default value” for a type. Read more
impl<'de, K, V> Deserialize<'de> for PrimaryMap<K, V> where
K: EntityRef,
V: Deserialize<'de>,
[src]
impl<'de, K, V> Deserialize<'de> for PrimaryMap<K, V> where
K: EntityRef,
V: Deserialize<'de>,
[src]fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]Deserialize this value from the given Serde deserializer. Read more
impl<__D: Fallible + ?Sized, K, V> Deserialize<PrimaryMap<K, V>, __D> for Archived<PrimaryMap<K, V>> where
K: EntityRef,
Vec<V>: Archive,
Archived<Vec<V>>: Deserialize<Vec<V>, __D>,
PhantomData<K>: Archive,
Archived<PhantomData<K>>: Deserialize<PhantomData<K>, __D>,
[src]
impl<__D: Fallible + ?Sized, K, V> Deserialize<PrimaryMap<K, V>, __D> for Archived<PrimaryMap<K, V>> where
K: EntityRef,
Vec<V>: Archive,
Archived<Vec<V>>: Deserialize<Vec<V>, __D>,
PhantomData<K>: Archive,
Archived<PhantomData<K>>: Deserialize<PhantomData<K>, __D>,
[src]Deserializes using the given deserializer
Creates a value from an iterator. Read more
Immutable indexing into an PrimaryMap
.
The indexed value must be in the map.
Mutable indexing into an PrimaryMap
.
Returns the size of the referenced value in bytes. Read more
impl<K: PartialEq, V: PartialEq> PartialEq<PrimaryMap<K, V>> for PrimaryMap<K, V> where
K: EntityRef,
[src]
impl<K: PartialEq, V: PartialEq> PartialEq<PrimaryMap<K, V>> for PrimaryMap<K, V> where
K: EntityRef,
[src]This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
impl<__S: Fallible + ?Sized, K, V> Serialize<__S> for PrimaryMap<K, V> where
K: EntityRef,
Vec<V>: Serialize<__S>,
PhantomData<K>: Serialize<__S>,
[src]
impl<__S: Fallible + ?Sized, K, V> Serialize<__S> for PrimaryMap<K, V> where
K: EntityRef,
Vec<V>: Serialize<__S>,
PhantomData<K>: Serialize<__S>,
[src]Auto Trait Implementations
impl<K, V> RefUnwindSafe for PrimaryMap<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for PrimaryMap<K, V> where
K: Send,
V: Send,
impl<K, V> Sync for PrimaryMap<K, V> where
K: Sync,
V: Sync,
impl<K, V> Unpin for PrimaryMap<K, V> where
K: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for PrimaryMap<K, V> where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Converts some archived metadata to the pointer metadata for itself.
The archived counterpart of this type. Unlike Archive
, it may be unsized.
type MetadataResolver = ()
type MetadataResolver = ()
The resolver for the metadata of this type.
pub fn resolve_metadata(
&self,
usize,
<T as ArchiveUnsized>::MetadataResolver,
&mut MaybeUninit<<<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata>
)
[src]
pub fn resolve_metadata(
&self,
usize,
<T as ArchiveUnsized>::MetadataResolver,
&mut MaybeUninit<<<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata>
)
[src]Creates the archived version of the metadata for this value at the given position and writes it to the given output. Read more
fn resolve_unsized(
&self,
from: usize,
to: usize,
resolver: Self::MetadataResolver,
out: &mut MaybeUninit<RelPtr<Self::Archived>>
)
[src]
fn resolve_unsized(
&self,
from: usize,
to: usize,
resolver: Self::MetadataResolver,
out: &mut MaybeUninit<RelPtr<Self::Archived>>
)
[src]Resolves a relative pointer to this value with the given from
and to
and writes it to
the given output. Read more
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
Writes the object and returns the position of the archived type.
pub fn serialize_metadata(
&self,
&mut S
) -> Result<<<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata, <S as Fallible>::Error>
[src]
pub fn serialize_metadata(
&self,
&mut S
) -> Result<<<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata, <S as Fallible>::Error>
[src]Serializes the metadata for the given type.