parent
0c904c40bb
commit
41b0d0da8d
30
src/lib.rs
30
src/lib.rs
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue