Skip to main content

Hook

Struct Hook 

Source
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: String

The hook’s name, surfaced in abort messages.

§callback: HookCallback

The underlying callback.

Implementations§

Source§

impl Hook

Source

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.

Source

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<EventLog> for Hook

Source§

fn from(event_log: EventLog) -> Hook

Converts to this type from the input type.
Source§

impl From<Logger> for Hook

Source§

fn from(logger: Logger) -> Hook

Converts to this type from the input type.
Source§

impl From<Profiler> for Hook

Source§

fn from(profiler: Profiler) -> Hook

Converts to this type from the input type.
Source§

impl From<StepFilter> for Hook

Source§

fn from(filter: StepFilter) -> Hook

Converts to this type from the input type.
Source§

impl From<StoreValidator> for Hook

Source§

fn from(validator: StoreValidator) -> Hook

Converts to this type from the input type.
Source§

impl From<Timeout> for Hook

Source§

fn from(timeout: Timeout) -> 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.