Trait HookRegistry Copy item path Source pub trait HookRegistry: Send + Sync {
// Required methods
fn register_hook (&mut self, hook: Hook ) -> Result <String >;
fn unregister_hook (&self, hook_id: &str ) -> Result <() >;
fn get_hook (&self, hook_id: &str ) -> Result <Hook >;
fn list_hooks (&self) -> Result <Vec <Hook >>;
fn list_hooks_for_event (&self, event: &str ) -> Result <Vec <Hook >>;
fn enable_hook (&mut self, hook_id: &str ) -> Result <() >;
fn disable_hook (&mut self, hook_id: &str ) -> Result <() >;
}Expand description Trait for managing hooks
The HookRegistry trait defines the interface for storing and managing hooks.
Implementations must support registering, unregistering, querying, and enabling/disabling hooks.
§ Thread Safety
All implementations must be thread-safe (Send + Sync) to support concurrent access.
Register a new hook
Stores a hook in the registry and returns its unique ID.
The hook will be assigned a unique ID if not already set.
§ Arguments
hook - The hook to register
§ Returns
The unique ID of the registered hook
§ Errors
Returns an error if the hook is invalid or registration fails
Unregister a hook by ID
Removes a hook from the registry.
§ Arguments
hook_id - The ID of the hook to unregister
§ Errors
Returns an error if the hook is not found
Get a hook by ID
Retrieves a hook from the registry by its ID.
§ Arguments
hook_id - The ID of the hook to retrieve
§ Returns
The hook with the specified ID
§ Errors
Returns an error if the hook is not found
List all hooks
Returns all hooks in the registry.
§ Returns
A vector of all hooks
§ Errors
Returns an error if listing fails
List hooks for a specific event
Returns all hooks registered for a specific event type.
Only enabled hooks are returned.
§ Arguments
event - The event type to filter by
§ Returns
A vector of hooks for the specified event
§ Errors
Returns an error if listing fails
Enable a hook
Enables a hook so it will be triggered when its event occurs.
§ Arguments
hook_id - The ID of the hook to enable
§ Errors
Returns an error if the hook is not found
Disable a hook
Disables a hook so it will not be triggered when its event occurs.
§ Arguments
hook_id - The ID of the hook to disable
§ Errors
Returns an error if the hook is not found