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

impl<K, V> PrimaryMap<K, V> where
    K: EntityRef
[src]

pub fn new() -> Self[src]

Create a new empty map.

pub fn with_capacity(capacity: usize) -> Self[src]

Create a new empty map with the given capacity.

pub fn is_valid(&self, k: K) -> bool[src]

Check if k is a valid key in the map.

pub fn get(&self, k: K) -> Option<&V>[src]

Get the element at k if it exists.

pub fn get_mut(&mut self, k: K) -> Option<&mut V>[src]

Get the element at k if it exists, mutable version.

pub fn is_empty(&self) -> bool[src]

Is this map completely empty?

pub fn len(&self) -> usize[src]

Get the total number of entity references created.

pub fn keys(&self) -> Keys<K>

Notable traits for Keys<K>

impl<K: EntityRef> Iterator for Keys<K> type Item = K;
[src]

Iterate over all the keys in this map.

pub fn values(&self) -> Iter<'_, V>

Notable traits for Iter<'a, T>

impl<'a, T> Iterator for Iter<'a, T> type Item = &'a T;
[src]

Iterate over all the values in this map.

pub fn values_mut(&mut self) -> IterMut<'_, V>

Notable traits for IterMut<'a, T>

impl<'a, T> Iterator for IterMut<'a, T> type Item = &'a mut T;
[src]

Iterate over all the values in this map, mutable edition.

pub fn iter(&self) -> Iter<'_, K, V>

Notable traits for Iter<'a, K, V>

impl<'a, K: EntityRef, V> Iterator for Iter<'a, K, V> type Item = (K, &'a V);
[src]

Iterate over all the keys and values in this map.

pub fn iter_mut(&mut self) -> IterMut<'_, K, V>

Notable traits for IterMut<'a, K, V>

impl<'a, K: EntityRef, V> Iterator for IterMut<'a, K, V> type Item = (K, &'a mut V);
[src]

Iterate over all the keys and values in this map, mutable edition.

pub fn clear(&mut self)[src]

Remove all entries from this map.

pub fn next_key(&self) -> K[src]

Get the key that will be assigned to the next pushed value.

pub fn push(&mut self, v: V) -> K[src]

Append v to the mapping, assigning a new key which is returned.

pub fn last(&self) -> Option<&V>[src]

Returns the last element that was inserted in the map.

pub fn reserve(&mut self, additional: usize)[src]

Reserves capacity for at least additional more elements to be inserted.

pub fn reserve_exact(&mut self, additional: usize)[src]

Reserves the minimum capacity for exactly additional more elements to be inserted.

pub fn shrink_to_fit(&mut self)[src]

Shrinks the capacity of the PrimaryMap as much as possible.

pub fn into_boxed_slice(self) -> BoxedSlice<K, V>[src]

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]

type Archived = ArchivedPrimaryMap<K, V>

The archived version of this type.

type Resolver = PrimaryMapResolver<K, V>

The resolver for this type. It must contain all the information needed to make the archived type from the normal type. Read more

fn resolve(
    &self,
    pos: usize,
    resolver: Self::Resolver,
    out: &mut MaybeUninit<Self::Archived>
)
[src]

Creates the archived version of this value at the given position and writes it to the given output. Read more

impl<K: Clone, V: Clone> Clone for PrimaryMap<K, V> where
    K: EntityRef
[src]

fn clone(&self) -> PrimaryMap<K, V>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<K: Debug, V: Debug> Debug for PrimaryMap<K, V> where
    K: EntityRef
[src]

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

Formats the value using the given formatter. Read more

impl<K, V> Default for PrimaryMap<K, V> where
    K: EntityRef
[src]

fn default() -> PrimaryMap<K, V>[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]

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<K, V> FromIterator<V> for PrimaryMap<K, V> where
    K: EntityRef
[src]

fn from_iter<T>(iter: T) -> Self where
    T: IntoIterator<Item = V>, 
[src]

Creates a value from an iterator. Read more

impl<K: Hash, V: Hash> Hash for PrimaryMap<K, V> where
    K: EntityRef
[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl<K, V> Index<K> for PrimaryMap<K, V> where
    K: EntityRef
[src]

Immutable indexing into an PrimaryMap. The indexed value must be in the map.

type Output = V

The returned type after indexing.

fn index(&self, k: K) -> &V[src]

Performs the indexing (container[index]) operation. Read more

impl<K, V> IndexMut<K> for PrimaryMap<K, V> where
    K: EntityRef
[src]

Mutable indexing into an PrimaryMap.

fn index_mut(&mut self, k: K) -> &mut V[src]

Performs the mutable indexing (container[index]) operation. Read more

impl<K, V> IntoIterator for PrimaryMap<K, V> where
    K: EntityRef
[src]

type Item = (K, V)

The type of the elements being iterated over.

type IntoIter = IntoIter<K, V>

Which kind of iterator are we turning this into?

fn into_iter(self) -> Self::IntoIter[src]

Creates an iterator from a value. Read more

impl<'a, K, V> IntoIterator for &'a PrimaryMap<K, V> where
    K: EntityRef
[src]

type Item = (K, &'a V)

The type of the elements being iterated over.

type IntoIter = Iter<'a, K, V>

Which kind of iterator are we turning this into?

fn into_iter(self) -> Self::IntoIter[src]

Creates an iterator from a value. Read more

impl<'a, K, V> IntoIterator for &'a mut PrimaryMap<K, V> where
    K: EntityRef
[src]

type Item = (K, &'a mut V)

The type of the elements being iterated over.

type IntoIter = IterMut<'a, K, V>

Which kind of iterator are we turning this into?

fn into_iter(self) -> Self::IntoIter[src]

Creates an iterator from a value. Read more

impl<K, V> MemoryUsage for PrimaryMap<K, V> where
    K: EntityRef,
    V: MemoryUsage
[src]

fn size_of_val(&self, tracker: &mut dyn MemoryUsageTracker) -> usize[src]

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]

fn eq(&self, other: &PrimaryMap<K, V>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &PrimaryMap<K, V>) -> bool[src]

This method tests for !=.

impl<K, V> Serialize for PrimaryMap<K, V> where
    K: EntityRef,
    V: Serialize
[src]

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
    __S: Serializer
[src]

Serialize this value into the given Serde serializer. Read more

impl<__S: Fallible + ?Sized, K, V> Serialize<__S> for PrimaryMap<K, V> where
    K: EntityRef,
    Vec<V>: Serialize<__S>,
    PhantomData<K>: Serialize<__S>, 
[src]

fn serialize(&self, serializer: &mut __S) -> Result<Self::Resolver, __S::Error>[src]

Writes the dependencies for the object and returns a resolver that can create the archived type. Read more

impl<K: Eq, V: Eq> Eq for PrimaryMap<K, V> where
    K: EntityRef
[src]

impl<K, V> StructuralEq for PrimaryMap<K, V> where
    K: EntityRef
[src]

impl<K, V> StructuralPartialEq for PrimaryMap<K, V> where
    K: EntityRef
[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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> ArchivePointee for T[src]

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.

pub fn pointer_metadata(
    &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
[src]

Converts some archived metadata to the pointer metadata for itself.

impl<T> ArchiveUnsized for T where
    T: Archive
[src]

type Archived = <T as Archive>::Archived

The archived counterpart of this type. Unlike Archive, it may be unsized.

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]

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]

Resolves a relative pointer to this value with the given from and to and writes it to the given output. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

pub fn equivalent(&self, key: &K) -> bool[src]

Compare self to key and return true if they are equal.

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Pointee for T

type Metadata = ()

The type for metadata in pointers and references to Self.

impl<T, S> SerializeUnsized<S> for T where
    T: Serialize<S>,
    S: Serializer + ?Sized
[src]

pub fn serialize_unsized(
    &self,
    serializer: &mut S
) -> Result<usize, <S as Fallible>::Error>
[src]

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]

Serializes the metadata for the given type.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]