use crate::*;
pub trait ServerHook: Send + Sync + 'static {
fn new(ctx: &Context) -> impl Future<Output = Self> + Send;
fn handle(self, ctx: &Context) -> impl Future<Output = ()> + Send;
}
pub trait AsyncFuncWithoutPin<Fut>: Fn(Context) -> Fut + Send + Sync + 'static
where
Fut: Future<Output = ()> + Send + 'static,
{
}
impl<T, Fut> AsyncFuncWithoutPin<Fut> for T
where
T: Fn(Context) -> Fut + Send + Sync + 'static,
Fut: Future<Output = ()> + Send + 'static,
{
}
#[derive(Clone, Copy, Debug)]
pub struct DefaultHook;
impl ServerHook for DefaultHook {
async fn new(_: &Context) -> Self {
Self
}
async fn handle(self, _: &Context) {}
}