Revert "Service::call takes &mut self"

This reverts commit dd51328a18.
This commit is contained in:
Aaron Turon 2017-01-09 13:47:21 -08:00
parent 0c904c40bb
commit 41b0d0da8d
1 changed files with 26 additions and 4 deletions

View File

@ -47,7 +47,7 @@ use std::sync::Arc;
/// type Error = http::Error;
/// type Future = Box<Future<Item = Self::Response, Error = http::Error>>;
///
/// 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<Future<Item = Self::Response, Error = Self::Error>>;
///
/// 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<Item = Self::Response, Error = Self::Error>;
/// 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<S: Service + ?Sized> Service for Box<S> {
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<S: Service + ?Sized> Service for Rc<S> {
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<S: Service + ?Sized> Service for Arc<S> {
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)
}
}