pub struct HandlerCache {
pub entries: HashMap<&'static str, HandlerEntry>,
pub entries_by_id: HashMap<TypeId, HandlerEntry>,
}Expand description
Runtime registry of compiled handler registrations.
Built at startup from HandlerRegistration inventory items.
Maps request type name to handler entry (factory + call bridge).
Unlike the previous design, entries do not cache a handler instance: the factory is invoked per request with the request-scoped resolver so Scoped dependencies (DbContext) are freshly owned each time.
Fields§
§entries: HashMap<&'static str, HandlerEntry>§entries_by_id: HashMap<TypeId, HandlerEntry>Implementations§
Source§impl HandlerCache
impl HandlerCache
Sourcepub fn build() -> HandlerCache
pub fn build() -> HandlerCache
Build the cache from all HandlerRegistration inventory items.
Sourcepub fn init_global()
pub fn init_global()
Initialize the global cache. Called once at host build time.
Sourcepub fn get_or_init() -> &'static HandlerCache
pub fn get_or_init() -> &'static HandlerCache
Get a reference to the global handler cache.
Must be called after init_global().
Sourcepub fn get(&self, req_type_name: &str) -> Option<&HandlerEntry>
pub fn get(&self, req_type_name: &str) -> Option<&HandlerEntry>
Look up a handler entry by request type name (route / OpenAPI diagnostics).
Sourcepub fn get_by_type_id(&self, type_id: TypeId) -> Option<&HandlerEntry>
pub fn get_by_type_id(&self, type_id: TypeId) -> Option<&HandlerEntry>
Look up a handler entry by request type id (Mediator / in-process dispatch).
Auto Trait Implementations§
impl Freeze for HandlerCache
impl RefUnwindSafe for HandlerCache
impl Send for HandlerCache
impl Sync for HandlerCache
impl Unpin for HandlerCache
impl UnsafeUnpin for HandlerCache
impl UnwindSafe for HandlerCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more