Remove FnService for now

Seems like it may not show up that often in practice, so let's cut down on scope
and concepts.
This commit is contained in:
Alex Crichton 2016-11-08 15:45:39 -08:00
parent 88962e3d2f
commit cbf48a2b8f
1 changed files with 0 additions and 41 deletions

View File

@ -210,47 +210,6 @@ impl<S: NewService + ?Sized> NewService for Rc<S> {
}
}
/// A service implemented by a closure.
pub struct FnService<F, R> {
f: F,
_ty: PhantomData<fn() -> R>, // don't impose Sync on R
}
/// Returns a `Service` backed by the given closure.
pub fn fn_service<F, R, S>(f: F) -> FnService<F, R>
where F: Fn(R) -> S,
S: IntoFuture,
{
FnService::new(f)
}
impl<F, R, S> FnService<F, R>
where F: Fn(R) -> S,
S: IntoFuture,
{
/// Create and return a new `FnService` backed by the given function.
pub fn new(f: F) -> FnService<F, R> {
FnService {
f: f,
_ty: PhantomData,
}
}
}
impl<F, R, S> Service for FnService<F, R>
where F: Fn(R) -> S,
S: IntoFuture
{
type Request = R;
type Response = S::Item;
type Error = S::Error;
type Future = S::Future;
fn call(&self, req: R) -> Self::Future {
(self.f)(req).into_future()
}
}
impl<S: Service + ?Sized> Service for Box<S> {
type Request = S::Request;
type Response = S::Response;