Skip to main content

Crate runtime_context

Crate runtime_context 

Source
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 Context type. Runtime context storing values by type.
TypeIdHasher
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 Any in 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 call downcast_ref, instead of failing or working on coerced &dyn Any it would work with type id of Box<dyn Any> itself instead of the type behind dyn Any.
ShareableTid
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 Any functionality 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 HashMap optimized for TypeId keys.