//! Handler future types. use crate::response::Response; use futures_util::future::Map; use http::Request; use pin_project_lite::pin_project; use std::{convert::Infallible, future::Future, pin::Pin, task::Context}; use tower::util::Oneshot; use tower_service::Service; opaque_future! { /// The response future for [`IntoService`](super::IntoService). pub type IntoServiceFuture = Map< F, fn(Response) -> Result, >; } pin_project! { /// The response future for [`Layered`](super::Layered). pub struct LayeredFuture where S: Service>, { #[pin] inner: Map>, fn(Result) -> Response>, } } impl LayeredFuture where S: Service>, { pub(super) fn new( inner: Map>, fn(Result) -> Response>, ) -> Self { Self { inner } } } impl Future for LayeredFuture where S: Service>, { type Output = Response; #[inline] fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> std::task::Poll { self.project().inner.poll(cx) } }