pub struct HookConfig {
pub hooks: HashMap<String, Vec<HookMatcher>>,
}Expand description
Top-level hooks configuration, typically loaded from settings.json.
The keys in the hooks map are event names (e.g., “PreToolUse”).
Unknown event names are silently dropped for forward compatibility.
Fields§
§hooks: HashMap<String, Vec<HookMatcher>>Map of event name to list of matchers.
Implementations§
Source§impl HookConfig
impl HookConfig
Sourcepub fn compile_all(&mut self)
pub fn compile_all(&mut self)
Compile all regex patterns in all matchers.
Call this after deserialization.
Sourcepub fn get_matchers(&self, event: HookEvent) -> &[HookMatcher]
pub fn get_matchers(&self, event: HookEvent) -> &[HookMatcher]
Get matchers for a given event. Returns an empty slice if none.
Sourcepub fn has_hooks_for(&self, event: HookEvent) -> bool
pub fn has_hooks_for(&self, event: HookEvent) -> bool
Fast check: are there any matchers registered for this event?
Sourcepub fn strip_unknown_events(&mut self)
pub fn strip_unknown_events(&mut self)
Remove any event keys that are not recognized. This provides forward compatibility — unknown events are silently dropped.
Sourcepub fn add_matcher(&mut self, event: HookEvent, matcher: HookMatcher)
pub fn add_matcher(&mut self, event: HookEvent, matcher: HookMatcher)
Register hooks for an event programmatically.
Trait Implementations§
Source§impl Clone for HookConfig
impl Clone for HookConfig
Source§fn clone(&self) -> HookConfig
fn clone(&self) -> HookConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HookConfig
impl Debug for HookConfig
Source§impl Default for HookConfig
impl Default for HookConfig
Source§fn default() -> HookConfig
fn default() -> HookConfig
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for HookConfig
impl<'de> Deserialize<'de> for HookConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for HookConfig
impl RefUnwindSafe for HookConfig
impl Send for HookConfig
impl Sync for HookConfig
impl Unpin for HookConfig
impl UnsafeUnpin for HookConfig
impl UnwindSafe for HookConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more