Hook Definition • Rust AI Agent SDK
HookDefinition: Hook definition
HookDefinition
Defined in the hooks module.
Rust AI Agent SDK
Hook definition
Fields
| Name | Type | Description |
|---|---|---|
id | String | Unique ID |
event | HookEvent | Event to hook |
matcher | Option<String> | Optional matcher pattern (regex for tool names, etc.) |
func | HookFn | Hook function |
enabled | bool | Whether hook is enabled |
name | Option<String> | Hook name (for debugging) |
Methods
new
fn new(
event: HookEvent,
func: impl Fn(&HookInput) -> HookResult + Send + Sync + 'static,
) -> SelfCreate a new hook definition
Parameters:
| Name | Type |
|---|---|
event | HookEvent |
func | impl Fn(&HookInput |
with_matcher
fn with_matcher(mut self, pattern: impl Into<String>) -> SelfSet matcher pattern
Parameters:
| Name | Type |
|---|---|
pattern | impl Into<String> |
with_name
fn with_name(mut self, name: impl Into<String>) -> SelfSet name
Parameters:
| Name | Type |
|---|---|
name | impl Into<String> |
matches
fn matches(&self, target: &str) -> boolCheck if this hook matches the target
Parameters:
| Name | Type |
|---|---|
target | &str |
execute
fn execute(&self, input: &HookInput) -> HookResultExecute the hook
Parameters:
| Name | Type |
|---|---|
input | &HookInput |
Source
View on GitHubpraisonai/src/hooks/mod.rs at line 285