async_svc/
ext.rs

1use std::marker::Sized;
2
3use crate::{box_svc, boxed::BoxSvc, MapSvc, Svc, ThenSvc};
4
5pub trait SvcExt<Req>: Svc<Req> {
6    fn map<F, Res>(self, f: F) -> MapSvc<Self, F, Res>
7    where
8        Self: Sized,
9        F: FnMut(Self::Res) -> Res,
10    {
11        MapSvc::new(self, f)
12    }
13
14    fn then<S2, Res>(self, svc2: S2) -> ThenSvc<Self, S2, Self::Res, Res>
15    where
16        Self: Sized,
17        S2: Svc<Self::Res, Res = Res>,
18    {
19        ThenSvc::new(self, svc2)
20    }
21
22    fn boxed(self) -> BoxSvc<Req, Self::Res>
23    where
24        Self: Sized + 'static,
25        Req: 'static,
26    {
27        box_svc(self)
28    }
29}