1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
use crate::*; /// Creates a new `ServerHookHandler` from a trait object. /// /// # Arguments /// /// - `ServerHook` - The trait object implementing `ServerHook`. /// /// # Returns /// /// - `ServerHookHandler` - A new `ServerHookHandler` instance. #[inline(always)] pub fn server_hook_factory<R>() -> ServerHookHandler where R: ServerHook, { Arc::new(move |ctx: &Context| -> SendableAsyncTask<()> { let ctx: Context = ctx.clone(); Box::pin(async move { R::new(&ctx).await.handle(&ctx).await; }) }) }