diff --git a/src/service/service.rs b/src/service/service.rs index c6db129bf4..1b9aea5162 100644 --- a/src/service/service.rs +++ b/src/service/service.rs @@ -38,3 +38,58 @@ pub trait Service { /// The discussion on this is here: fn call(&self, req: Request) -> Self::Future; } + +impl + ?Sized> Service for &'_ S { + type Response = S::Response; + type Error = S::Error; + type Future = S::Future; + + #[inline] + fn call(&self, req: Request) -> Self::Future { + (**self).call(req) + } +} + +impl + ?Sized> Service for &'_ mut S { + type Response = S::Response; + type Error = S::Error; + type Future = S::Future; + + #[inline] + fn call(&self, req: Request) -> Self::Future { + (**self).call(req) + } +} + +impl + ?Sized> Service for Box { + type Response = S::Response; + type Error = S::Error; + type Future = S::Future; + + #[inline] + fn call(&self, req: Request) -> Self::Future { + (**self).call(req) + } +} + +impl + ?Sized> Service for std::rc::Rc { + type Response = S::Response; + type Error = S::Error; + type Future = S::Future; + + #[inline] + fn call(&self, req: Request) -> Self::Future { + (**self).call(req) + } +} + +impl + ?Sized> Service for std::sync::Arc { + type Response = S::Response; + type Error = S::Error; + type Future = S::Future; + + #[inline] + fn call(&self, req: Request) -> Self::Future { + (**self).call(req) + } +}