pub trait HookExecutor: Send + Sync {
// Required methods
fn execute_hook(
&self,
hook: &Hook,
context: &EventContext,
) -> Result<HookResult>;
fn execute_action(
&self,
hook: &Hook,
context: &EventContext,
) -> Result<String>;
}Expand description
Trait for executing hooks
The HookExecutor is responsible for:
- Receiving hooks and event context
- Evaluating hook conditions
- Executing hook actions (commands, tool calls, AI prompts, chains)
- Handling timeouts and errors
- Capturing output and results
- Providing hook isolation (failures don’t affect other hooks)
§Examples
ⓘ
let executor = DefaultHookExecutor::new();
let hook = Hook { ... };
let context = EventContext { ... };
let result = executor.execute_hook(&hook, &context)?;Required Methods§
Sourcefn execute_hook(
&self,
hook: &Hook,
context: &EventContext,
) -> Result<HookResult>
fn execute_hook( &self, hook: &Hook, context: &EventContext, ) -> Result<HookResult>
Execute a hook with the given context
This method:
- Evaluates the hook condition (if present)
- Executes the hook action
- Captures output and errors
- Returns a HookResult with status and output
Sourcefn execute_action(&self, hook: &Hook, context: &EventContext) -> Result<String>
fn execute_action(&self, hook: &Hook, context: &EventContext) -> Result<String>
Execute a hook action
Routes to the appropriate executor based on action type:
- CommandAction: Execute shell command
- ToolCallAction: Call tool with parameters
- AiPromptAction: Send prompt to AI assistant
- ChainAction: Execute hooks in sequence