1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
use axum::{async_trait, extract::FromRequestParts, http::request::Parts, response::IntoResponse};
use axum_macros::debug_handler;
fn main() {}
#[debug_handler]
fn concrete_future() -> std::future::Ready<Result<impl IntoResponse, ()>> {
std::future::ready(Ok(()))
}
#[debug_handler]
fn impl_future() -> impl std::future::Future<Output = Result<impl IntoResponse, ()>> {
std::future::ready(Ok(()))
}
// === no args ===
#[debug_handler]
async fn handler_no_arg_one() -> Result<impl IntoResponse, ()> {
Ok(())
}
#[debug_handler]
async fn handler_no_arg_two() -> Result<(), impl IntoResponse> {
Err(())
}
#[debug_handler]
async fn handler_no_arg_three() -> Result<impl IntoResponse, impl IntoResponse> {
Ok::<_, ()>(())
}
#[debug_handler]
async fn handler_no_arg_four() -> Result<impl IntoResponse, impl IntoResponse> {
Err::<(), _>(())
}
// === args ===
#[debug_handler]
async fn handler_one(foo: String) -> Result<impl IntoResponse, ()> {
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<impl IntoResponse, impl IntoResponse> {
dbg!(foo);
Ok::<_, ()>(())
}
#[debug_handler]
async fn handler_four(foo: String) -> Result<impl IntoResponse, impl IntoResponse> {
dbg!(foo);
Err::<(), _>(())
}
// === no args with receiver ===
struct A;
impl A {
#[debug_handler]
async fn handler_no_arg_one(self) -> Result<impl IntoResponse, ()> {
Ok(())
}
#[debug_handler]
async fn handler_no_arg_two(self) -> Result<(), impl IntoResponse> {
Err(())
}
#[debug_handler]
async fn handler_no_arg_three(self) -> Result<impl IntoResponse, impl IntoResponse> {
Ok::<_, ()>(())
}
#[debug_handler]
async fn handler_no_arg_four(self) -> Result<impl IntoResponse, impl IntoResponse> {
Err::<(), _>(())
}
}
// === args with receiver ===
impl A {
#[debug_handler]
async fn handler_one(self, foo: String) -> Result<impl IntoResponse, ()> {
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<impl IntoResponse, impl IntoResponse> {
dbg!(foo);
Ok::<_, ()>(())
}
#[debug_handler]
async fn handler_four(self, foo: String) -> Result<impl IntoResponse, impl IntoResponse> {
dbg!(foo);
Err::<(), _>(())
}
}
#[async_trait]
impl<S> FromRequestParts<S> for A
where
S: Send + Sync,
{
type Rejection = ();
async fn from_request_parts(_parts: &mut Parts, _state: &S) -> Result<Self, Self::Rejection> {
unimplemented!()
}
}
|