|
31 | 31 | //! impl HttpService for Server {
|
32 | 32 | //! type Connection = ();
|
33 | 33 | //! type ConnectionFuture = future::Ready<Result<(), std::io::Error>>;
|
34 |
| -//! type Fut = FutureObj<'static, Result<http_service::Response, std::io::Error>>; |
| 34 | +//! type ResponseFuture = FutureObj<'static, Result<http_service::Response, std::io::Error>>; |
35 | 35 | //!
|
36 | 36 | //! fn connect(&self) -> Self::ConnectionFuture {
|
37 | 37 | //! future::ok(())
|
38 | 38 | //! }
|
39 | 39 | //!
|
40 |
| -//! fn respond(&self, _conn: &mut (), _req: http_service::Request) -> Self::Fut { |
| 40 | +//! fn respond(&self, _conn: &mut (), _req: http_service::Request) -> Self::ResponseFuture { |
41 | 41 | //! let message = self.message.clone();
|
42 | 42 | //! FutureObj::new(Box::new(
|
43 | 43 | //! async move {
|
@@ -164,29 +164,29 @@ pub trait HttpService: Send + Sync + 'static {
|
164 | 164 | /// Returning an error will result in the server immediately dropping
|
165 | 165 | /// the connection. It is usually preferable to instead return an HTTP response
|
166 | 166 | /// with an error status code.
|
167 |
| - type Fut: Send + 'static + TryFuture<Ok = Response>; |
| 167 | + type ResponseFuture: Send + 'static + TryFuture<Ok = Response>; |
168 | 168 |
|
169 | 169 | /// Begin handling a single request.
|
170 | 170 | ///
|
171 | 171 | /// The handler is given shared access to the service itself, and mutable access
|
172 | 172 | /// to the state for the connection where the request is taking place.
|
173 |
| - fn respond(&self, conn: &mut Self::Connection, req: Request) -> Self::Fut; |
| 173 | + fn respond(&self, conn: &mut Self::Connection, req: Request) -> Self::ResponseFuture; |
174 | 174 | }
|
175 | 175 |
|
176 |
| -impl<F, Fut> HttpService for F |
| 176 | +impl<F, R> HttpService for F |
177 | 177 | where
|
178 |
| - F: Send + Sync + 'static + Fn(Request) -> Fut, |
179 |
| - Fut: Send + 'static + TryFuture<Ok = Response>, |
180 |
| - Fut::Error: Send, |
| 178 | + F: Send + Sync + 'static + Fn(Request) -> R, |
| 179 | + R: Send + 'static + TryFuture<Ok = Response>, |
| 180 | + R::Error: Send, |
181 | 181 | {
|
182 | 182 | type Connection = ();
|
183 |
| - type ConnectionFuture = future::Ready<Result<(), Fut::Error>>; |
| 183 | + type ConnectionFuture = future::Ready<Result<(), R::Error>>; |
184 | 184 | fn connect(&self) -> Self::ConnectionFuture {
|
185 | 185 | future::ok(())
|
186 | 186 | }
|
187 | 187 |
|
188 |
| - type Fut = Fut; |
189 |
| - fn respond(&self, _: &mut (), req: Request) -> Self::Fut { |
| 188 | + type ResponseFuture = R; |
| 189 | + fn respond(&self, _: &mut (), req: Request) -> Self::ResponseFuture { |
190 | 190 | (self)(req)
|
191 | 191 | }
|
192 | 192 | }
|
0 commit comments