pub struct Hook {
pub name: String,
pub callback: HookCallback,
}Expand description
An observer or interceptor attached to a pipeline via
Pipeline::hook.
Construct with Hook::observer for read-only event tracing or
Hook::interceptor for callbacks that can abort the pipeline.
Built-in hooks (Logger,
Profiler,
StepFilter, and friends) implement
Into<Hook> so they can be passed directly to Pipeline::hook.
Fields§
§name: StringThe hook’s name, surfaced in abort messages.
callback: HookCallbackThe underlying callback.
Implementations§
Source§impl Hook
impl Hook
Sourcepub fn observer(
name: impl Into<String>,
f: impl Fn(&HookEvent<'_>, &Store<StoreEntry>) + Send + 'static,
) -> Self
pub fn observer( name: impl Into<String>, f: impl Fn(&HookEvent<'_>, &Store<StoreEntry>) + Send + 'static, ) -> Self
Wraps a closure as a read-only observer hook. Observers cannot abort the pipeline.
Sourcepub fn interceptor(
name: impl Into<String>,
f: impl Fn(&HookEvent<'_>, &Store<StoreEntry>) -> HookAction + Send + 'static,
) -> Self
pub fn interceptor( name: impl Into<String>, f: impl Fn(&HookEvent<'_>, &Store<StoreEntry>) -> HookAction + Send + 'static, ) -> Self
Wraps a closure as an interceptor hook. Interceptors inspect
each event and return a HookAction — use HookAction::Abort
to stop the pipeline.
Trait Implementations§
Source§impl From<StepFilter> for Hook
impl From<StepFilter> for Hook
Source§fn from(filter: StepFilter) -> Hook
fn from(filter: StepFilter) -> Hook
Converts to this type from the input type.
Source§impl From<StoreValidator> for Hook
impl From<StoreValidator> for Hook
Source§fn from(validator: StoreValidator) -> Hook
fn from(validator: StoreValidator) -> Hook
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Hook
impl !RefUnwindSafe for Hook
impl Send for Hook
impl !Sync for Hook
impl Unpin for Hook
impl UnsafeUnpin for Hook
impl !UnwindSafe for Hook
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