How is the Repository pattern usually used in Rust?
I'm currently working on a project in Rust, but I'm already familiar with languages like PHP, JavaScript (Node.js), and C#.
In my project, I'm using Axum + diesel-async (PostgreSQL) and I've reached the stage where I need to set up the database connection and everything related to it. I want to apply the Repository pattern, but I've run into a problem: I don't understand where I should store the db_pool.
Should it go into the global AppState (like in most examples - although to me this feels wrong because everything gets mixed together there, like db_pool, config, etc.) or into something like infrastructure/db.rs?
Also, how should I pass &mut AsyncPgConnection to the repository? ChatGPT suggests getting it in the service layer via pool.get and then passing it to the repository method - but that doesn't feel right to me, because it mixes layers. If we follow DDD, the repository should hide all the details of data access.
I’ve already spent quite a lot of time researching this, but unfortunately haven't found a clear answer yet. I'd really like to find the "right" approach to this pattern in Rust - I guess that's my perfectionism talking :).
Thanks in advance for your help!