Closed mubarak23 closed 1 month ago
getting specific state value not fix this error @Marchand-Nicolas
error[E0277]: the trait bound `fn(axum::extract::State<Arc<AppState>>, Extension<std::string::String>, axum::Json<create_balance::CreateBalance>) -> impl futures::Future<Output = impl IntoResponse> {create_balance::handler}: Handler<_, _, _>` is not satisfied
--> src/endpoints/admin/balance/create_balance.rs:30:14
|
29 | #[route(post, "/admin/tasks/balance/create", auth_middleware)]
| -------------------------------------------------------------- required by a bound introduced by this call
30 | pub async fn handler(
| ^^^^^^^ the trait `Handler<_, _, _>` is not implemented for fn item `fn(State<Arc<AppState>>, Extension<String>, Json<CreateBalance>) -> impl Future<Output = impl IntoResponse> {handler}`
|
= help: the following other types implement trait `Handler<T, S, B>`:
<Layered<L, H, T, S, B, B2> as Handler<T, S, B2>>
<MethodRouter<S, B> as Handler<(), S, B>>
note: required by a bound in `post`
--> /Users/macbookpro/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-0.6.20/src/routing/method_routing.rs:407:1
|
407 | top_level_handler_fn!(post, POST);
| ^^^^^^^^^^^^^^^^^^^^^^----^^^^^^^
| | |
| | required by a bound in this function
| required by this bound in `post`
= note: this error originates in the macro `top_level_handler_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
@mubarak23 Maybe check how we do in the other handlers to manage async functions calls
Hello @mubarak23 OD hack ends on Sunday (6). Everything okay ?
Hello, just got enough time to look at your problem @mubarak23 .
You are using Mutex from the std lib, which is not really usable inside of async functions. The best solution is to use Mutex from the Tokio Sync library: use tokio::sync::Mutex;
You can then simply do:
let state_last_id = state.last_task_id.lock().await;
Draft PR for issue #274