use axum::{extract::FromRequestParts, http::request::Parts, response::IntoResponse}; use axum_macros::debug_handler; fn main() {} #[debug_handler] fn concrete_future() -> std::future::Ready> { std::future::ready(Ok(())) } #[debug_handler] fn impl_future() -> impl std::future::Future> { std::future::ready(Ok(())) } // === no args === #[debug_handler] async fn handler_no_arg_one() -> Result { Ok(()) } #[debug_handler] async fn handler_no_arg_two() -> Result<(), impl IntoResponse> { Err(()) } #[debug_handler] async fn handler_no_arg_three() -> Result { Ok::<_, ()>(()) } #[debug_handler] async fn handler_no_arg_four() -> Result { Err::<(), _>(()) } // === args === #[debug_handler] async fn handler_one(foo: String) -> Result { dbg!(foo); Ok(()) } #[debug_handler] async fn handler_two(foo: String) -> Result<(), impl IntoResponse> { dbg!(foo); Err(()) } #[debug_handler] async fn handler_three(foo: String) -> Result { dbg!(foo); Ok::<_, ()>(()) } #[debug_handler] async fn handler_four(foo: String) -> Result { dbg!(foo); Err::<(), _>(()) } // === no args with receiver === struct A; impl A { #[debug_handler] async fn handler_no_arg_one(self) -> Result { Ok(()) } #[debug_handler] async fn handler_no_arg_two(self) -> Result<(), impl IntoResponse> { Err(()) } #[debug_handler] async fn handler_no_arg_three(self) -> Result { Ok::<_, ()>(()) } #[debug_handler] async fn handler_no_arg_four(self) -> Result { Err::<(), _>(()) } } // === args with receiver === impl A { #[debug_handler] async fn handler_one(self, foo: String) -> Result { dbg!(foo); Ok(()) } #[debug_handler] async fn handler_two(self, foo: String) -> Result<(), impl IntoResponse> { dbg!(foo); Err(()) } #[debug_handler] async fn handler_three(self, foo: String) -> Result { dbg!(foo); Ok::<_, ()>(()) } #[debug_handler] async fn handler_four(self, foo: String) -> Result { dbg!(foo); Err::<(), _>(()) } } impl FromRequestParts for A where S: Send + Sync, { type Rejection = (); async fn from_request_parts(_parts: &mut Parts, _state: &S) -> Result { unimplemented!() } }