What is r2d2 and how does it work?
masterr2d2 is a generic connection pool for Rust. It prevents the inefficiency and resource exhaustion caused by opening a new database connection for every request by maintaining a set of open connections and handing them out for repeated use.
Because r2d2 is agnostic to the connection type, it relies on the ManageConnection trait. Implementors of this trait provide the specific logic required to create new connections and check their health. Most common databases have existing adaptor crates (e.g., r2d2-postgres, r2d2-sqlite) that implement this trait for you.