Skip to main content

HookRegistry

Defined in the hooks module.
Rust AI Agent SDK Hook registry for managing hooks

Fields

NameTypeDescription
hooksHashMap<HookEvent-

Methods

new

fn new() -> Self
Create a new hook registry

add_hook

fn add_hook(
        &mut self,
        event: HookEvent,
        func: impl Fn(&HookInput) -> HookResult + Send + Sync + 'static,
    ) -> &mut Self
Add a hook Parameters:
NameType
eventHookEvent
funcimpl 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 Self
Add a hook with matcher Parameters:
NameType
eventHookEvent
matcherimpl Into&lt;String&gt;
funcimpl Fn(&HookInput

add_definition

fn add_definition(&mut self, hook: HookDefinition) -> &mut Self
Add a hook definition Parameters:
NameType
hookHookDefinition

remove_hook

fn remove_hook(&mut self, id: &str) -> bool
Remove a hook by ID Parameters:
NameType
id&str

has_hooks

fn has_hooks(&self, event: HookEvent) -> bool
Check if any hooks exist for an event Parameters:
NameType
eventHookEvent

hook_count

fn hook_count(&self, event: HookEvent) -> usize
Get hook count for an event Parameters:
NameType
eventHookEvent

execute

fn execute(&self, event: HookEvent, input: &HookInput) -> HookResult
Execute all hooks for an event Parameters:
NameType
eventHookEvent
input&HookInput

execute_async

async fn execute_async(&self, event: HookEvent, input: &HookInput) -> HookResult
Execute hooks asynchronously (for future async hooks) Parameters:
NameType
eventHookEvent
input&HookInput

Source

View on GitHub

praisonai/src/hooks/mod.rs at line 359