use std::marker::PhantomData; use futures::future::{ok, FutureResult}; use futures::{Async, Poll}; use super::{NewService, Service}; /// Empty service #[derive(Clone)] pub struct Blank { _t: PhantomData<(R, E)>, } impl Blank { pub fn err(self) -> Blank { Blank { _t: PhantomData } } } impl Blank { #[allow(clippy::new_ret_no_self)] pub fn new() -> Blank { Blank { _t: PhantomData } } } impl Default for Blank { fn default() -> Blank { Blank { _t: PhantomData } } } impl Service for Blank { type Request = R; type Response = R; type Error = E; type Future = FutureResult; fn poll_ready(&mut self) -> Poll<(), Self::Error> { Ok(Async::Ready(())) } fn call(&mut self, req: R) -> Self::Future { ok(req) } } /// Empty service factory pub struct BlankNewService { _t: PhantomData<(R, E1, E2)>, } impl BlankNewService { pub fn new() -> BlankNewService { BlankNewService { _t: PhantomData } } } impl BlankNewService { pub fn new_unit() -> BlankNewService { BlankNewService { _t: PhantomData } } } impl Default for BlankNewService { fn default() -> BlankNewService { Self::new() } } impl NewService for BlankNewService { type Request = R; type Response = R; type Error = E1; type Config = (); type Service = Blank; type InitError = E2; type Future = FutureResult; fn new_service(&self, _: &()) -> Self::Future { ok(Blank::default()) } }