Help using postgres prepared statements with r2d2 connection pool

Hi everyone, I'm writing an application that uses the postgres crate along with r2d2 to create a connection pool. I'd like to use prepared statements because the application is going to query based on user specified input, but I can't find a way to use prepare_cached to create the statements a single time, I have to create a new statement every time a connection from the pool interacts with the database.

I think I need to use a custom r2d2 connection pool Builder, along with CustomizeConnection to create the prepare_cached statements for each connection, but I couldn't find any examples of this being done, and I'm not sure how I'd access the prepare_cached statements of a connection after it's retrieved from the pool.

Does anyone know of any projects I could look at as an example? Also, this is my first time writing an application that interacts with a database (just a learning exercise), so if I'm going about this in a completely wrong manner, that'd be helpful to know as well.

prepare_cached is "transparent" - you use it just like prepare except that the statements are cached internally. They're actually prepared the first time you call prepare_cached and that's then reused in subsequent calls.