zon_core 0.0.4

part of a new WIP, very incomplete async http service stack
Documentation
use std::{future::Future, sync::Arc};

use crate::Response;

pub trait HttpService<B: Send>: Sync {
    type ResponseBody;

    fn call(
        &self,
        request: http::Request<B>,
    ) -> impl Future<Output = Response<Self::ResponseBody>> + Send;
}

impl<B, S> HttpService<B> for &S
where
    B: Send,
    S: HttpService<B>,
{
    type ResponseBody = S::ResponseBody;

    fn call(
        &self,
        request: http::Request<B>,
    ) -> impl Future<Output = Response<Self::ResponseBody>> + Send {
        (**self).call(request)
    }
}

impl<B, S> HttpService<B> for Box<S>
where
    B: Send,
    S: HttpService<B>,
{
    type ResponseBody = S::ResponseBody;

    fn call(
        &self,
        request: http::Request<B>,
    ) -> impl Future<Output = http::Response<Self::ResponseBody>> + Send {
        (**self).call(request)
    }
}

impl<B, S> HttpService<B> for Arc<S>
where
    B: Send,
    S: HttpService<B> + Send,
{
    type ResponseBody = S::ResponseBody;

    fn call(
        &self,
        request: http::Request<B>,
    ) -> impl Future<Output = Response<Self::ResponseBody>> + Send {
        (**self).call(request)
    }
}