Skip to content
Discussion options

You must be logged in to vote

For those reading along the answer appears to be that R2D2's pooled connection type is a smart pointer. And if you find yourself in my situation (where you have a database abstraction layer that expects a certain specific/non-generic type of connection) you can change a &mut PooledConnection<ConnectionManager<PgConnection>> into a &mut PgConnection via the deref trait ie. my_pooled_connection.deref_mut()

Thankfully in my internal library all I need to do is change

pub type DbConnection = PooledConnection<ConnectionManager<PgConnection>>;

into

pub type DbConnection = PgConnection;

and call .deref_mut() in a few places. And then I'll be able to use the TransactionBuilder API without runni…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@kairoswater-jason
Comment options

Answer selected by kairoswater-jason
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants