I am upgrading an application to the new Postgres driver that uses async/await.
This portion of the original code builds an object that holds a connection and a transaction linked to it:
fn new_simple_mut(
conn: Connection,
) -> Result<rentals::SimpleMut, C3p0Error> {
rentals::SimpleMut::try_new_or_drop(Box::new(conn), |c| {
let tx = c.transaction()?; <-- THIS FUNCTION IS ASYNC IN THE NEW DRIVER VERSION
Ok(Some(tx))
})
}
rental! {
mod rentals {
use super::*;
#[rental_mut]
pub struct SimpleMut {
conn: Box<Connection>,
tx: Option<Transaction<'conn>>,
}
}
}
In the new version of the Postgres driver, the connection.transaction() function is async so I should use .await but the try_new_or_drop does not accept it.
Is there a way to achieve what I need with rental?
I am upgrading an application to the new Postgres driver that uses async/await. This portion of the original code builds an object that holds a connection and a transaction linked to it:
In the new version of the Postgres driver, the
connection.transaction()
function is async so I should use.await
but thetry_new_or_drop
does not accept it. Is there a way to achieve what I need with rental?