Expand description
Runtime context for storing heterogeneous values by type.
This crate provides a lightweight type map with support for owned values and
borrowed (immutable or mutable) references. It is built on top of
better_any and uses an optimized
TypeId hasher for fast lookups.
Macros§
- tid
- Re-export public API. Main safe implementation interface of related unsafe traits
- type_id
- Re-export public API. Main safe implementation interface of related unsafe traits
Structs§
- Context
- Re-export the main
Contexttype. Runtime context storing values by type. - Type
IdHasher - A hasher for
TypeIds that takes advantage of its known characteristics.
Enums§
- Data
- Re-export internal modules for users who need advanced features.
Stored value variants inside a
Context.
Traits§
- AnyExt
- Re-export public API.
Methods here are implemented as an associated functions because otherwise
for one they will conflict with methods defined on
dyn Anyin stdlib, for two they will be available on almost every type in the program causing confusing bugs and error messages For example if you have&Box<dyn Any>and calldowncast_ref, instead of failing or working on coerced&dyn Anyit would work with type id ofBox<dyn Any>itself instead of the type behinddyn Any. - Shareable
Tid - Re-export internal modules for users who need advanced features.
Thread-safe variant of
Tid. - Tid
- Re-export public API.
This trait indicates that this type can be converted to
trait object with typeid while preserving lifetime information.
Extends
Anyfunctionality for types with single lifetime - TidAble
- Re-export public API.
This trait indicates that you can substitute this type as a type parameter to
another type so that resulting type could implement
Tid. - TidExt
- Re-export public API. Extension trait that contains actual downcasting methods.
Functions§
- typeid_
of - Re-export public API.
Returns type id of
T
Type Aliases§
- TypeMap
- A
HashMapoptimized forTypeIdkeys.