pub trait Hook:
Send
+ Sync
+ 'static {
type Args<'b>;
type Result;
// Required method
fn call<'a>(
&'a self,
args: Self::Args<'a>,
next: &dyn for<'c> Fn(Self::Args<'c>) -> Self::Result,
) -> Self::Result;
}
Expand description
A Trait for hooks. Implements this trait to create a hook.
Required Associated Types§
Required Methods§
Sourcefn call<'a>(
&'a self,
args: Self::Args<'a>,
next: &dyn for<'c> Fn(Self::Args<'c>) -> Self::Result,
) -> Self::Result
fn call<'a>( &'a self, args: Self::Args<'a>, next: &dyn for<'c> Fn(Self::Args<'c>) -> Self::Result, ) -> Self::Result
The hook function. This will be called when the target function is called.
§Parameters:
args
: The arguments of the target function.next
: The next function to call. This is the next hook or original target function.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.