mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-19 00:00:14 +02:00
44 lines
1.1 KiB
Rust
44 lines
1.1 KiB
Rust
//! Handler future types.
|
|
|
|
use crate::body::BoxBody;
|
|
use http::{Request, Response};
|
|
use pin_project_lite::pin_project;
|
|
use std::{
|
|
convert::Infallible,
|
|
future::Future,
|
|
pin::Pin,
|
|
task::{Context, Poll},
|
|
};
|
|
use tower::Service;
|
|
|
|
opaque_future! {
|
|
/// The response future for [`IntoService`](super::IntoService).
|
|
pub type IntoServiceFuture =
|
|
futures_util::future::BoxFuture<'static, Result<Response<BoxBody>, Infallible>>;
|
|
}
|
|
|
|
pin_project! {
|
|
/// The response future for [`OnMethod`](super::OnMethod).
|
|
#[derive(Debug)]
|
|
pub struct OnMethodFuture<S, F, B>
|
|
where
|
|
S: Service<Request<B>>,
|
|
F: Service<Request<B>>
|
|
{
|
|
#[pin]
|
|
pub(super) inner: crate::routing::future::RouteFuture<S, F, B>,
|
|
}
|
|
}
|
|
|
|
impl<S, F, B> Future for OnMethodFuture<S, F, B>
|
|
where
|
|
S: Service<Request<B>, Response = Response<BoxBody>>,
|
|
F: Service<Request<B>, Response = Response<BoxBody>, Error = S::Error>,
|
|
{
|
|
type Output = Result<Response<BoxBody>, S::Error>;
|
|
|
|
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
|
self.project().inner.poll(cx)
|
|
}
|
|
}
|