@@ -14,6 +14,7 @@ use axum::{
14
14
routing:: { get, post} ,
15
15
Json , Router ,
16
16
} ;
17
+ use futures_util:: future:: BoxFuture ;
17
18
use serde:: { Deserialize , Serialize } ;
18
19
use serde_json:: json;
19
20
use std:: sync:: Arc ;
@@ -109,12 +110,12 @@ impl IntoResponse for AppError {
109
110
struct ExampleUserRepo ;
110
111
111
112
impl UserRepo for ExampleUserRepo {
112
- async fn find ( & self , _user_id : Uuid ) -> Result < User , UserRepoError > {
113
- unimplemented ! ( )
113
+ fn find ( & self , _user_id : Uuid ) -> BoxFuture < Result < User , UserRepoError > > {
114
+ Box :: pin ( async { unimplemented ! ( ) } )
114
115
}
115
116
116
- async fn create ( & self , _params : CreateUser ) -> Result < User , UserRepoError > {
117
- unimplemented ! ( )
117
+ fn create ( & self , _params : CreateUser ) -> BoxFuture < Result < User , UserRepoError > > {
118
+ Box :: pin ( async { unimplemented ! ( ) } )
118
119
}
119
120
}
120
121
@@ -124,10 +125,10 @@ type DynUserRepo = Arc<dyn UserRepo + Send + Sync>;
124
125
/// A trait that defines things a user repo might support.
125
126
trait UserRepo {
126
127
/// Loop up a user by their id.
127
- async fn find ( & self , user_id : Uuid ) -> Result < User , UserRepoError > ;
128
+ fn find ( & self , user_id : Uuid ) -> BoxFuture < Result < User , UserRepoError > > ;
128
129
129
130
/// Create a new user.
130
- async fn create ( & self , params : CreateUser ) -> Result < User , UserRepoError > ;
131
+ fn create ( & self , params : CreateUser ) -> BoxFuture < Result < User , UserRepoError > > ;
131
132
}
132
133
133
134
#[ derive( Debug , Serialize ) ]
0 commit comments