diff --git a/src/lib.rs b/src/lib.rs index e1cd1ee..75ce9f5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,7 +47,7 @@ use std::sync::Arc; /// type Error = http::Error; /// type Future = Box>; /// -/// fn call(&mut self, req: http::Request) -> Self::Future { +/// fn call(&self, req: http::Request) -> Self::Fut { /// // Create the HTTP response /// let resp = http::Response::ok() /// .with_body(b"hello world\n"); @@ -120,7 +120,7 @@ use std::sync::Arc; /// type Error = T::Error; /// type Future = Box>; /// -/// fn call(&mut self, req: Self::Request) -> Self::Future { +/// fn call(&self, req: Self::Req) -> Self::Fut { /// let timeout = self.timer.timeout(self.delay) /// .and_then(|timeout| Err(Self::Error::from(timeout))); /// @@ -152,7 +152,7 @@ pub trait Service { type Future: Future; /// Process the request and return the response asynchronously. - fn call(&mut self, req: Self::Request) -> Self::Future; + fn call(&self, req: Self::Request) -> Self::Future; } /// Creates new `Service` values. @@ -215,7 +215,29 @@ impl Service for Box { type Error = S::Error; type Future = S::Future; - fn call(&mut self, request: S::Request) -> S::Future { + fn call(&self, request: S::Request) -> S::Future { + (**self).call(request) + } +} + +impl Service for Rc { + type Request = S::Request; + type Response = S::Response; + type Error = S::Error; + type Future = S::Future; + + fn call(&self, request: S::Request) -> S::Future { + (**self).call(request) + } +} + +impl Service for Arc { + type Request = S::Request; + type Response = S::Response; + type Error = S::Error; + type Future = S::Future; + + fn call(&self, request: S::Request) -> S::Future { (**self).call(request) } }