Struct matrix_appservice_rs::MappingDict[][src]

pub struct MappingDict<V: Mappable> { /* fields omitted */ }
Expand description

A map comparable to a HashMap which contains items that are Mappable. The map keeps track of the mapping between both the external type and Matrix type and an object.

Implementations

impl<V> MappingDict<V> where
    V: Mappable
[src]

pub fn new() -> Self[src]

Create a new empty MappingDict.

pub fn from_vec(items: Vec<V>) -> Self[src]

Create a new MappingDict consuming the given Vec of items. All items are put into the newly created map.

This is more efficient than just calling insert yourself on an empty map, since this method will initialize the vector and hashmap with a starting capacpity, thus resulting in less allocations.

pub fn insert(&mut self, item: V) -> &mut V[src]

Inserts the given item in the current MappingDict. Allocates if neccesary.

Returns a mutable reference to the newly inserted item.

pub fn get(
    &self,
    identifier: MappingId<'_, V::ExternalReference, V::MatrixReference>
) -> Option<&V>
[src]

Returns a reference to the item associated with the given identifier, or None if no such item exists.

pub fn get_mut(
    &mut self,
    identifier: MappingId<'_, V::ExternalReference, V::MatrixReference>
) -> Option<&mut V>
[src]

Returns a mutable reference to the item associated with the given identifier, or None if no such item exists.

pub fn has(
    &self,
    identifier: MappingId<'_, V::ExternalReference, V::MatrixReference>
) -> bool
[src]

Returns whether or not this MappingDict contains an item associated with the given identifier.

pub fn remove(
    &mut self,
    identifier: MappingId<'_, V::ExternalReference, V::MatrixReference>
) -> Option<V>
[src]

If this MappingDict contains an item associated with the given identifier, remove it and return the value that was contained in the MappingDict. If no such item exists, this function returns None.

pub fn iter(&self) -> Iter<'_, V>[src]

Get an iterator over references of the items contained in this MappingDict.

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

Get an iterator over mutable references of the items contained in this MappingDict.

pub fn shrink_to_fit(&mut self)[src]

Shrinks the capacity of the map as much as possible. It will drop down as much as possible while maintaining the internal rules and possibly leaving some space in accordance with the resize policy.

Trait Implementations

impl<V: Clone + Mappable> Clone for MappingDict<V> where
    V::ExternalType: Clone,
    V::MatrixType: Clone
[src]

fn clone(&self) -> MappingDict<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<V: Debug + Mappable> Debug for MappingDict<V> where
    V::ExternalType: Debug,
    V::MatrixType: Debug
[src]

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

Formats the value using the given formatter. Read more

impl<T: Mappable> Default for MappingDict<T>[src]

fn default() -> Self[src]

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

impl<'a, T> IntoIterator for &'a MappingDict<T> where
    T: Mappable
[src]

type Item = &'a T

The type of the elements being iterated over.

type IntoIter = Iter<'a, T>

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<V> IntoIterator for MappingDict<V> where
    V: Mappable
[src]

type Item = V

The type of the elements being iterated over.

type IntoIter = IntoIter<Self::Item>

Which kind of iterator are we turning this into?

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

Creates an iterator from a value. Read more

Auto Trait Implementations

impl<V> RefUnwindSafe for MappingDict<V> where
    V: RefUnwindSafe,
    <V as Mappable>::ExternalType: RefUnwindSafe,
    <V as Mappable>::MatrixType: RefUnwindSafe

impl<V> Send for MappingDict<V> where
    V: Send,
    <V as Mappable>::ExternalType: Send,
    <V as Mappable>::MatrixType: Send

impl<V> Sync for MappingDict<V> where
    V: Sync,
    <V as Mappable>::ExternalType: Sync,
    <V as Mappable>::MatrixType: Sync

impl<V> Unpin for MappingDict<V> where
    V: Unpin,
    <V as Mappable>::ExternalType: Unpin,
    <V as Mappable>::MatrixType: Unpin

impl<V> UnwindSafe for MappingDict<V> where
    V: UnwindSafe,
    <V as Mappable>::ExternalType: UnwindSafe,
    <V as Mappable>::MatrixType: 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> 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<T> From<T> for T[src]

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

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

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

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

Performs the conversion.

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.