use multi_trait_object::MultitraitObject; use std::any::Any; /// A trait that allows using the object implementing it /// to be used as a type key. pub trait TypeMapKey: 'static { type Value: Any; } /// A trait used for restricting values inserted in a type map /// using type checking pub trait TypedKeyTrait: 'static { type Value: TypedKeyMto; } /// A trait used to create a multitrait-object from a given /// value with the given guaranteed trait implementations pub trait TypedKeyMto { fn into_mto(self) -> MultitraitObject; } /// A trait implemented by all typemaps that provides /// all basic typemap functions pub trait TypeMapTrait { type Key; /// Creates a new typemap fn new() -> Self; /// Inserts a value into the typemap with the given key fn insert>(&mut self, value: T::Value); /// Returns a reference to a value from the type map with the given provided key fn get>(&self) -> Option<&T::Value>; /// Returns a mutable reference to a value from the type map with the given provided key fn get_mut>(&mut self) -> Option<&mut T::Value>; /// Removes a value from the map for the given key fn remove>(&mut self) -> Option; /// Returns if the map contains a given key fn contains_key>(&self) -> bool; }