rambl_rs 0.1.10

An HTTP server framework
Documentation
#![allow(dead_code)]

use std::pin::Pin;
use crate::{Context, Responder, Response};

pub trait HandlerFunc<U>: Send + Sync {
    fn call(&self, res: Responder, ctx: Context<U>) -> Pin<Box<dyn Future<Output = ()> + Send>>;
}

impl<T, Fut, U> HandlerFunc<U> for T 
where
    T: Fn(Responder, Context<U>) -> Fut + Send + Sync + 'static,
    Fut: Future<Output = ()> + Send + 'static
{
    fn call(&self, res: Responder, ctx: Context<U>) -> Pin<Box<dyn Future<Output = ()> + Send>> {
        Box::pin(self(res, ctx))
    }
}

pub enum Handler<U=()> {
    Active(Box<dyn HandlerFunc<U>>),
    Static(Box<dyn Response>)
}