pub struct HookMatcher {
pub phases: Vec<HookPhase>,
pub tool_name: Option<String>,
pub cwd_prefix: Option<String>,
}Expand description
Pure filter that gates a hook on phase, tool name, and/or cwd prefix.
phases empty = all phases match. tool_name / cwd_prefix None = no constraint.
Allocation: O(phases count + name/prefix length) at construction.
Fields§
§phases: Vec<HookPhase>Phases this hook applies to. Empty = all phases.
tool_name: Option<String>Exact tool name filter (for PreToolUse). None = any tool.
cwd_prefix: Option<String>Working-directory prefix filter. None = any cwd.
Implementations§
Source§impl HookMatcher
impl HookMatcher
Sourcepub fn phases(phases: impl Into<Vec<HookPhase>>) -> Self
pub fn phases(phases: impl Into<Vec<HookPhase>>) -> Self
Match only specific phases. Allocation: one Vec. Complexity: O(phases count).
Sourcepub fn with_tool_name(self, name: impl Into<String>) -> Self
pub fn with_tool_name(self, name: impl Into<String>) -> Self
Add exact tool_name constraint (meaningful for PreToolUse). Allocation: one String. Complexity: O(name length).
Sourcepub fn with_cwd_prefix(self, prefix: impl Into<String>) -> Self
pub fn with_cwd_prefix(self, prefix: impl Into<String>) -> Self
Add cwd_prefix constraint. Uses str::starts_with matching.
Allocation: one String. Complexity: O(prefix length).
Sourcepub fn matches(&self, ctx: &HookContext) -> bool
pub fn matches(&self, ctx: &HookContext) -> bool
True when ctx satisfies all non-empty constraints.
cwd_prefix matches cwd == prefix or cwd starts with prefix + "/".
This avoids treating /project as a prefix of /project2.
Pure function; no heap allocation. Complexity: O(phases count + prefix length).
Trait Implementations§
Source§impl Clone for HookMatcher
impl Clone for HookMatcher
Source§fn clone(&self) -> HookMatcher
fn clone(&self) -> HookMatcher
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more