[][src]Struct iron::TypeMap

pub struct TypeMap<A = dyn UnsafeAny + 'static> where
    A: UnsafeAnyExt + ?Sized
{ /* fields omitted */ }

A map keyed by types.

Can contain one value of any type for each key type, as defined by the Assoc trait.

You usually do not need to worry about the A type parameter, but it can be used to add bounds to the possible value types that can be stored in this map. Usually, you are looking for ShareMap, which is Send + Sync.

Methods

impl TypeMap<dyn UnsafeAny + 'static>[src]

pub fn new() -> TypeMap<dyn UnsafeAny + 'static>[src]

Create a new, empty TypeMap.

impl<A> TypeMap<A> where
    A: UnsafeAnyExt + ?Sized
[src]

pub fn custom() -> TypeMap<A>[src]

Create a new, empty TypeMap.

Can be used with any A parameter; new is specialized to get around the required type annotations when using this function.

pub fn insert<K>(&mut self, val: <K as Key>::Value) -> Option<<K as Key>::Value> where
    K: Key,
    <K as Key>::Value: Any,
    <K as Key>::Value: Implements<A>, 
[src]

Insert a value into the map with a specified key type.

pub fn get<K>(&self) -> Option<&<K as Key>::Value> where
    K: Key,
    <K as Key>::Value: Any,
    <K as Key>::Value: Implements<A>, 
[src]

Find a value in the map and get a reference to it.

pub fn get_mut<K>(&mut self) -> Option<&mut <K as Key>::Value> where
    K: Key,
    <K as Key>::Value: Any,
    <K as Key>::Value: Implements<A>, 
[src]

Find a value in the map and get a mutable reference to it.

pub fn contains<K>(&self) -> bool where
    K: Key
[src]

Check if a key has an associated value stored in the map.

pub fn remove<K>(&mut self) -> Option<<K as Key>::Value> where
    K: Key,
    <K as Key>::Value: Any,
    <K as Key>::Value: Implements<A>, 
[src]

Remove a value from the map.

Returns true if a value was removed.

pub fn entry<K>(&'a mut self) -> Entry<'a, K, A> where
    K: Key,
    <K as Key>::Value: Any,
    <K as Key>::Value: Implements<A>, 
[src]

Get the given key's corresponding entry in the map for in-place manipulation.

pub unsafe fn data(&self) -> &HashMap<TypeId, Box<A>, RandomState>[src]

Read the underlying HashMap

pub unsafe fn data_mut(&mut self) -> &mut HashMap<TypeId, Box<A>, RandomState>[src]

Get a mutable reference to the underlying HashMap

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

Get the number of values stored in the map.

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

Return true if the map contains no values.

pub fn clear(&mut self)[src]

Remove all entries from the map.

Trait Implementations

impl<A> Default for TypeMap<A> where
    A: Default + UnsafeAnyExt + ?Sized
[src]

impl<A> Debug for TypeMap<A> where
    A: Debug + UnsafeAnyExt + ?Sized
[src]

impl<A> Clone for TypeMap<A> where
    A: UnsafeAnyExt + ?Sized,
    Box<A>: Clone
[src]

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

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl<A: ?Sized> Unpin for TypeMap<A>

impl<A: ?Sized> Sync for TypeMap<A> where
    A: Sync

impl<A: ?Sized> Send for TypeMap<A> where
    A: Send

impl<A: ?Sized> UnwindSafe for TypeMap<A> where
    A: UnwindSafe

impl<A: ?Sized> RefUnwindSafe for TypeMap<A> where
    A: RefUnwindSafe

Blanket Implementations

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

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

type Owned = T

The resulting type after obtaining ownership.

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

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.

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.

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

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

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

impl<T> Typeable for T where
    T: Any

fn get_type(&self) -> TypeId

Get the TypeId of this object.

impl<T> DebugAny for T where
    T: Any + Debug
[src]

impl<T> CloneAny for T where
    T: Clone + Any
[src]

impl<T> UnsafeAny for T where
    T: Any