pub struct FilteredPreHook<H: PreHook> { /* private fields */ }Expand description
A PreHook wrapper that runs the inner hook only when matcher passes.
On mismatch, returns HookAction::Noop without invoking the inner hook.
Allocation: none per call when matcher fails. Complexity: O(matcher check).
Implementations§
Source§impl<H: PreHook> FilteredPreHook<H>
impl<H: PreHook> FilteredPreHook<H>
Sourcepub fn new(hook: H, matcher: HookMatcher) -> Self
pub fn new(hook: H, matcher: HookMatcher) -> Self
Wrap hook so it only fires when matcher passes.
Allocation: one HookMatcher clone. Complexity: O(1).
Trait Implementations§
Source§impl<H: PreHook> PreHook for FilteredPreHook<H>
impl<H: PreHook> PreHook for FilteredPreHook<H>
fn name(&self) -> &'static str
fn call<'a>( &'a self, ctx: &'a HookContext, ) -> HookFuture<'a, Result<HookAction, HookIssue>>
Auto Trait Implementations§
impl<H> Freeze for FilteredPreHook<H>where
H: Freeze,
impl<H> RefUnwindSafe for FilteredPreHook<H>where
H: RefUnwindSafe,
impl<H> Send for FilteredPreHook<H>
impl<H> Sync for FilteredPreHook<H>
impl<H> Unpin for FilteredPreHook<H>where
H: Unpin,
impl<H> UnsafeUnpin for FilteredPreHook<H>where
H: UnsafeUnpin,
impl<H> UnwindSafe for FilteredPreHook<H>where
H: UnwindSafe,
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