Testable interface for diesel using with dyn trait(dynamic dispatching)

Hi guys!

We are developing a web application using rocket and diesel, but have to call for help on making an interface that allows using a stubbed database for running (unit)tests.

The problem that I need help with, is the Connection.transaction function of diesel, which has generic type parameters. These parameters make it hard to add the function to our test interface.

I have tried to make an example of the problem, you can see that on this playground share.

I can think of this workaround,
enum ConnectionType { MySQL(conn: MySQLConnection), Test(conn: MockConnection) }
Where both the types have a transaction call, and the can be fetched like:
fn get_database(&self) -> ConnectionType;

How would you solve this? Is there a way to do this with dynamic dispatching, or do I really need a workaround?