Not sure why is this happening, here's a snippet:
struct:
use serde::Deserialize;
#[derive(Deserialize, Debug)]
pub struct Snapshot<'a> {
id : u32,
some_data : &'a str
}
impl<'a> SomeStruct{
async fn snapshot(url: &str) -> Result<Snapshot<'a>, Box<dyn std::error::Error>> {
let resp = reqwest::get(&url).await?;
let snapshot = resp.json::<Snapshot>().await?;
println!("{:?}", resp);
Ok(snapshot)
}
}
error message: on the json line
mismatched types
one type is more general than the other
note: expected trait `models::requests::_::_serde::Deserialize<'de>`
found trait `models::requests::_::_serde::Deserialize<'_>`rustc(E0308)
I imagine this has something to do with the lifecycle of the elements on struct snapshot, but I'm not sure how to properly fix it.
Cargo.toml:
[dependencies]
actix-web = "3"
reqwest = { version = "0.11.6", features = ["json"] }
async-trait = "0.1.51"
serde = "1.0.130"