Currently I am able to use the following code, but I do not want to have to cast my JSON to text in my postgres query since it adds latency.
async fn reverse_geocode(min : f32, max : f32, pool: &Pool) -> Result<String, PoolError> {
let client: Client = pool.get().await?;
let sql = format!("select \"json\"::TEXT from get_data({}, {})", min, max);
let stmt = client.prepare(&sql).await?;
let rows = client.query(&stmt, &[]).await?;
Ok(rows[0].get(0))
}
If I do not cast my JSON to text, I get the following error:
error retrieving column 0: error deserializing column 0: cannot convert between the Rust type `alloc::string::String` and the Postgres type `jsonb`
What type can be used so that I return that json value without casting it to text?