tower_http_util/service/
into_service.rs

1use super::HttpService;
2use futures::Poll;
3use http::{Request, Response};
4use tower_service::Service;
5
6/// Wraps an `HttpService` instance, implementing `tower_service::Service`.
7///
8/// See [`into_service`] function documentation for more details.
9///
10/// [`into_service`]: #
11#[derive(Debug)]
12pub struct IntoService<T> {
13    inner: T,
14}
15
16impl<T> IntoService<T> {
17    pub(crate) fn new(inner: T) -> IntoService<T> {
18        IntoService { inner }
19    }
20}
21
22impl<T, ReqBody> Service<Request<ReqBody>> for IntoService<T>
23where
24    T: HttpService<ReqBody>,
25{
26    type Response = Response<T::ResponseBody>;
27    type Error = T::Error;
28    type Future = T::Future;
29
30    fn poll_ready(&mut self) -> Poll<(), Self::Error> {
31        self.inner.poll_ready()
32    }
33
34    fn call(&mut self, request: Request<ReqBody>) -> Self::Future {
35        self.inner.call(request)
36    }
37}