> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Add Hook With Matcher • Rust AI Agent SDK

> add_hook_with_matcher: Add a hook with matcher

# add\_hook\_with\_matcher

<div className="flex items-center gap-2">
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**HookRegistry**](../classes/HookRegistry) class in the [**hooks**](../modules/hooks) module.

Add a hook with matcher

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8B0000', 'primaryTextColor': '#fff', 'primaryBorderColor': '#710101', 'lineColor': '#189AB4', 'secondaryColor': '#189AB4', 'tertiaryColor': '#fff' }}}%%

graph TD
    event["Event Trigger"] --> hook["Hook: add_hook_with_matcher"]
    hook --> decision{"Decision"}
    decision -- "Allow" --> proc["Process"]
    decision -- "Deny" --> block["Block"]
    style hook fill:#189AB4,color:#fff
    style event fill:#8B0000,color:#fff
    style proc fill:#8B0000,color:#fff
    style block fill:#8B0000,color:#fff
```

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def add_hook_with_matcher(
        &mut self,
        event: HookEvent,
        matcher: impl Into<String>,
        func: impl Fn(&HookInput) -> HookResult + Send + Sync + 'static,
    ) -> &mut Self
```

## Parameters

<ParamField query="event" type="HookEvent" required={true}>
  No description available.
</ParamField>

<ParamField query="matcher" type="impl Into<String>" required={true}>
  No description available.
</ParamField>

<ParamField query="func" type="impl Fn(&HookInput" required={true}>
  No description available.
</ParamField>

### Returns

<ResponseField
  name="Returns"
  type="HookResult + Send + Sync + 'static,
) -> &mut Self"
>
  The result of the operation.
</ResponseField>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Rust Hooks" icon="anchor" href="/docs/rust/hooks" />

  <Card title="Rust Events" icon="bolt" href="/docs/rust/events" />

  <Card title="Rust Callbacks" icon="phone" href="/docs/rust/callbacks" />
</CardGroup>
