pub struct HookRegistry { /* private fields */ }Expand description
Central registry for all hooks.
Hooks are indexed by HookPoint for O(1) lookup.
Within each point, hooks are sorted by priority (ascending).
§Concurrency
Use Arc<std::sync::RwLock<HookRegistry>> for concurrent access:
dispatch()takes&self(read lock)register()/unregister()take&mut self(write lock)
Implementations§
Source§impl HookRegistry
impl HookRegistry
Sourcepub fn register(&mut self, hook: Box<dyn Hook>) -> String
pub fn register(&mut self, hook: Box<dyn Hook>) -> String
Registers a hook. Returns the hook’s ID.
The hook is inserted in priority order (ascending).
Sourcepub fn register_owned(
&mut self,
hook: Box<dyn Hook>,
owner: ComponentId,
) -> String
pub fn register_owned( &mut self, hook: Box<dyn Hook>, owner: ComponentId, ) -> String
Registers a hook owned by a component.
Owned hooks are automatically unregistered when
unregister_by_owner() is called (e.g., on component shutdown).
Sourcepub fn unregister(&mut self, id: &str) -> bool
pub fn unregister(&mut self, id: &str) -> bool
Unregisters a hook by ID. Returns true if found and removed.
Sourcepub fn unregister_by_owner(&mut self, owner: &ComponentId) -> usize
pub fn unregister_by_owner(&mut self, owner: &ComponentId) -> usize
Unregisters all hooks owned by the given component.
Returns the number of hooks removed.
Sourcepub fn set_enabled(&mut self, id: &str, enabled: bool)
pub fn set_enabled(&mut self, id: &str, enabled: bool)
Enables or disables a hook by ID.
Sourcepub fn dispatch(
&self,
point: HookPoint,
component_id: &ComponentId,
child_id: Option<&str>,
ctx: HookContext,
) -> HookAction
pub fn dispatch( &self, point: HookPoint, component_id: &ComponentId, child_id: Option<&str>, ctx: HookContext, ) -> HookAction
Dispatches hooks for the given point and target.
Hooks are executed in priority order (ascending). Chain semantics:
- Pre-hook:
SkiporAbort→ stop chain immediately - Post-hook:
Replace→ update payload, continue chain - Disabled hooks and FQL non-matches are skipped
- Depth exceeded → break with warning
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HookRegistry
impl !RefUnwindSafe for HookRegistry
impl Send for HookRegistry
impl Sync for HookRegistry
impl Unpin for HookRegistry
impl UnsafeUnpin for HookRegistry
impl !UnwindSafe for HookRegistry
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