Skip to main content

IntoAsyncHook

Trait IntoAsyncHook 

Source
pub trait IntoAsyncHook<K: HookEvent>:
    for<'a, 'b> Fn(&'b mut K::Event<'a>) -> BoxFuture<'b, Self::Output>
    + Send
    + Sync
    + 'static {
    type Output: HookOutput;
}
Expand description

An async closure usable as a hook for the event K: it returns Box::pin(async move { .. }) whose output is a HookOutput.

Implemented for every such closure; name the event with add_async_hook::<E>.

Required Associated Types§

Source

type Output: HookOutput

What the closure’s future returns.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<K, F, R> IntoAsyncHook<K> for F
where K: HookEvent, F: for<'a, 'b> Fn(&'b mut K::Event<'a>) -> BoxFuture<'b, R> + Send + Sync + 'static, R: HookOutput,