Hook Registry • Rust AI Agent SDK
HookRegistry: Hook registry for managing hooks
HookRegistry
Defined in the hooks module.
Rust AI Agent SDK
Hook registry for managing hooks
Fields
| Name | Type | Description |
|---|---|---|
hooks | HashMap<HookEvent | – |
Methods
new
fn new() -> SelfCreate a new hook registry
add_hook
fn add_hook(
&mut self,
event: HookEvent,
func: impl Fn(&HookInput) -> HookResult + Send + Sync + 'static,
) -> &mut SelfAdd a hook
Parameters:
| Name | Type |
|---|---|
event | HookEvent |
func | impl Fn(&HookInput |
add_hook_with_matcher
fn add_hook_with_matcher(
&mut self,
event: HookEvent,
matcher: impl Into<String>,
func: impl Fn(&HookInput) -> HookResult + Send + Sync + 'static,
) -> &mut SelfAdd a hook with matcher
Parameters:
| Name | Type |
|---|---|
event | HookEvent |
matcher | impl Into<String> |
func | impl Fn(&HookInput |
add_definition
fn add_definition(&mut self, hook: HookDefinition) -> &mut SelfAdd a hook definition
Parameters:
| Name | Type |
|---|---|
hook | HookDefinition |
remove_hook
fn remove_hook(&mut self, id: &str) -> boolRemove a hook by ID
Parameters:
| Name | Type |
|---|---|
id | &str |
has_hooks
fn has_hooks(&self, event: HookEvent) -> boolCheck if any hooks exist for an event
Parameters:
| Name | Type |
|---|---|
event | HookEvent |
hook_count
fn hook_count(&self, event: HookEvent) -> usizeGet hook count for an event
Parameters:
| Name | Type |
|---|---|
event | HookEvent |
execute
fn execute(&self, event: HookEvent, input: &HookInput) -> HookResultExecute all hooks for an event
Parameters:
| Name | Type |
|---|---|
event | HookEvent |
input | &HookInput |
execute_async
async fn execute_async(&self, event: HookEvent, input: &HookInput) -> HookResultExecute hooks asynchronously (for future async hooks)
Parameters:
| Name | Type |
|---|---|
event | HookEvent |
input | &HookInput |
Source
View on GitHubpraisonai/src/hooks/mod.rs at line 359