尽管为Axum端点实现处理程序功能,但我运行以下错误
--> qubic-rpc/src/lib.rs:90:38
|
90 | .route("/balances/{id}", get(routes::wallet_balance))
| --- ^^^^^^^^^^^^^^^^^^^^^^ the trait `Handler<_, _>`
| is not implemented for fn item
| `fn(axum::extract::Path<QubicWallet>) -> impl Future<Output = impl IntoResponse> {wallet_balance}`
|
| required by a bound introduced by this call
|
这里的定义:
:
wallet_balance
所有我的其他端点都可以正常工作,当我评论pub async fn wallet_balance(Path(_wallet): Path<QubicWallet>) -> impl IntoResponse {
(StatusCode::NOT_IMPLEMENTED, "Not implemented yet")
}
行时,代码编译。我做了一些挖掘,发现人们通常会出现此错误时有三个主要问题:
他们调用该功能,而不是将其传递给
.route("/balances/{id}", get(routes::wallet_balance))
fnasync
我的案例:通过提取器作为参数传递的一种类型之一,在这种情况下,不实现
route
特征。
我能够使用
.route("/balances/{id}", get(routes::wallet_balance()))
):添加了您的
QubicWallet
Deserialize
debug_handler
macros
对axum
解决问题。