Type Alias parity_wasm::elements::NameMap

source ·
pub type NameMap = IndexMap<String>;
Expand description

A map from indices to names.

Aliased Type§

struct NameMap { /* private fields */ }

Implementations

source§

impl<T> IndexMap<T>

source

pub fn with_capacity(capacity: usize) -> IndexMap<T>

Create an empty IndexMap, preallocating enough space to store capacity entries without needing to reallocate the underlying memory.

source

pub fn clear(&mut self)

Clear the map.

source

pub fn get(&self, idx: u32) -> Option<&T>

Return the name for the specified index, if it exists.

source

pub fn contains_key(&self, idx: u32) -> bool

Does the map contain an entry for the specified index?

source

pub fn insert(&mut self, idx: u32, value: T) -> Option<T>

Insert a name into our map, returning the existing value if present.

Note: This API is designed for reasonably dense indices based on valid data. Inserting a huge idx will use up a lot of RAM, and this function will not try to protect you against that.

source

pub fn remove(&mut self, idx: u32) -> Option<T>

Remove an item if present and return it.

source

pub fn len(&self) -> usize

The number of items in this map.

source

pub fn is_empty(&self) -> bool

Is this map empty?

source

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

Create a non-consuming iterator over this IndexMap’s keys and values.

source

pub fn deserialize_with<R, F>( max_entry_space: usize, deserialize_value: &F, rdr: &mut R, ) -> Result<IndexMap<T>, Error>
where R: Read, F: Fn(u32, &mut R) -> Result<T, Error>,

Custom deserialization routine.

We will allocate an underlying array no larger than max_entry_space to hold the data, so the maximum index must be less than max_entry_space. This prevents mallicious *.wasm files from having a single entry with the index u32::MAX, which would consume far too much memory.

The deserialize_value function will be passed the index of the value being deserialized, and must deserialize the value.

source§

impl<T> IndexMap<T>
where T: Deserialize, Error: From<<T as Deserialize>::Error>,

source

pub fn deserialize<R: Read>( max_entry_space: usize, rdr: &mut R, ) -> Result<Self, Error>

Deserialize a map containing simple values that support Deserialize. We will allocate an underlying array no larger than max_entry_space to hold the data, so the maximum index must be less than max_entry_space.

Trait Implementations

source§

impl<T: Clone> Clone for IndexMap<T>

source§

fn clone(&self) -> IndexMap<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for IndexMap<T>

source§

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

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

impl<T: Default> Default for IndexMap<T>

source§

fn default() -> IndexMap<T>

Returns the “default value” for a type. Read more
source§

impl<T> FromIterator<(u32, T)> for IndexMap<T>

source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = (u32, T)>,

Create an IndexMap from an iterator.

Note: This API is designed for reasonably dense indices based on valid data. Inserting a huge idx will use up a lot of RAM, and this function will not try to protect you against that.

source§

impl<T> IntoIterator for IndexMap<T>

§

type Item = (u32, T)

The type of the elements being iterated over.
§

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> IntoIter<T>

Creates an iterator from a value. Read more
source§

impl<T: PartialEq> PartialEq for IndexMap<T>

source§

fn eq(&self, other: &IndexMap<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> Serialize for IndexMap<T>
where T: Serialize, Error: From<<T as Serialize>::Error>,

§

type Error = Error

Serialization error produced by serialization routine.
source§

fn serialize<W: Write>(self, wtr: &mut W) -> Result<(), Self::Error>

Serialize type to serial i/o
source§

impl<T: Eq> Eq for IndexMap<T>