Hi all,
I'm new to Rust and am having a tough time trying to decipher this error message:
the trait bound
reqwest::error::Error: _IMPL_DESERIALIZE_FOR_User::_serde::Serialize is not satisfied
.
For context, the first function get_canvas_self
below works correctly, but I'm not sure how to write the second function canvas_self
(which is an endpoint for returning the result of the call to get_canvas_self
).
async fn get_canvas_self() -> Result<User, Error> {
dotenv().ok();
let base_url = env::var("CANVAS_API_DOMAIN").expect("Canvas API Domain not set in .env");
let token = env::var("CANVAS_API_TOKEN").expect("Canvas Token not set in .env");
let endpoint = "/users/self";
let client = reqwest::Client::new();
let response = client
.get(&format!("{}{}", base_url, endpoint))
.header("Authorization", &format!("Bearer {}", token))
.send()
.await?
.json::<User>()
.await?;
Ok(response)
}
#[get("/canvas_self")]
async fn canvas_self() -> Result<HttpResponse, Error> {
let self_response = get_canvas_self().await;
Ok(HttpResponse::Ok().json(self_response))
}
The full error is:
error[E0277]: the trait bound `reqwest::error::Error: _IMPL_DESERIALIZE_FOR_User::_serde::Serialize` is not satisfied
--> src/main.rs:41:32
|
41 | Ok(HttpResponse::Ok().json(self_response))
| ^^^^^^^^^^^^^ the trait `_IMPL_DESERIALIZE_FOR_User::_serde::Serialize` is not implemented for `reqwest::error::Error`
|
= note: required because of the requirements on the impl of `_IMPL_DESERIALIZE_FOR_User::_serde::Serialize` for `std::result::Result<User, reqwest::error::Error>
Thanks for your help!