pub type StateMap = HashMap<TypeId, Arc<dyn Any + Send + Sync>>;Expand description
The type-keyed state a Server carries into every request.
Each Server::with_state::<T>(value) registers one entry; every
RequestContext clones an Arc<StateMap> rather than the values
themselves, so a thousand in-flight requests pay a thousand Arc
bumps rather than a thousand deep copies.
Any rather than a typed HashMap<TypeId, T> because a server
accumulates entries for different Ts — a database pool, a
configuration, a metrics handle — and a typed map is only one of
those at a time. The Send + Sync bounds on the values match what
every other port in this crate asks for.
Aliased Type§
pub struct StateMap { /* private fields */ }