zon_core 0.0.4

part of a new WIP, very incomplete async http service stack
Documentation
use crate::either::Either;

mod tuples;

pub trait HttpMiddleware<S> {
    type Service;

    fn apply(self, inner: S) -> Self::Service;
}

/// The unit type can be used as a no-op middleware, mapping `S` to itself.
impl<S> HttpMiddleware<S> for () {
    type Service = S;

    fn apply(self, service: S) -> Self::Service {
        service
    }
}

impl<S, M> HttpMiddleware<S> for Option<M>
where
    M: HttpMiddleware<S>,
{
    type Service = Either<M::Service, S>;

    fn apply(self, inner: S) -> Self::Service {
        match self {
            Some(mid) => Either::A(mid.apply(inner)),
            None => Either::B(inner),
        }
    }
}