1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::future::Future;
use futures_util::future::BoxFuture;
use crate::request::ctx::Ctx;
use crate::response::Response;

pub trait Next: Send + Sync {
    fn call(&self, ctx: Ctx) -> BoxFuture<'static, crate::path::Result<Response>>;
}

impl<F, Fut> Next for F where
    F: Fn(Ctx) -> Fut + Sync + Send,
    Fut: Future<Output = crate::path::Result<Response>> + Send + 'static {
    fn call(&self, ctx: Ctx) -> BoxFuture<'static, crate::path::Result<Response>> {
        Box::pin(self(ctx))
    }
}