pub struct HookMatcher {
pub event: HookEvent,
pub tool_name: Option<String>,
pub callback: HookCallback,
pub timeout: Option<Duration>,
}Expand description
A hook registration that pairs a lifecycle event with a callback.
Fields§
§event: HookEventThe event type this hook matches.
tool_name: Option<String>Optional tool name filter. If Some, only matches the named tool.
If None, matches all tools for the given event.
callback: HookCallbackThe callback to invoke when the hook matches.
timeout: Option<Duration>Optional timeout for the callback. If None, uses the default.
Implementations§
Source§impl HookMatcher
impl HookMatcher
Sourcepub fn new(event: HookEvent, callback: HookCallback) -> Self
pub fn new(event: HookEvent, callback: HookCallback) -> Self
Create a new hook matcher for the given event with the given callback.
Sourcepub fn for_tool(self, name: impl Into<String>) -> Self
pub fn for_tool(self, name: impl Into<String>) -> Self
Filter this hook to only match a specific tool name.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set a timeout for this hook’s callback.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HookMatcher
impl !RefUnwindSafe for HookMatcher
impl Send for HookMatcher
impl Sync for HookMatcher
impl Unpin for HookMatcher
impl UnsafeUnpin for HookMatcher
impl !UnwindSafe for HookMatcher
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more