diff --git a/contrib/db_pools/lib/src/database.rs b/contrib/db_pools/lib/src/database.rs index e6a21c76..8b67706f 100644 --- a/contrib/db_pools/lib/src/database.rs +++ b/contrib/db_pools/lib/src/database.rs @@ -214,6 +214,37 @@ impl Initializer { } } +impl Connection { + /// Returns the internal connection value. See the [`Connection` Deref + /// column](crate#supported-drivers) for the expected type of this value. + /// + /// Note that `Connection` derefs to the internal connection type, so + /// using this method is likely unnecessary. See [deref](Connection#deref) + /// for examples. + /// + /// # Example + /// + /// ```rust + /// # #[cfg(feature = "sqlx_sqlite")] mod _inner { + /// # use rocket::get; + /// # type Pool = rocket_db_pools::sqlx::SqlitePool; + /// use rocket_db_pools::{Database, Connection}; + /// + /// #[derive(Database)] + /// #[database("db")] + /// struct Db(Pool); + /// + /// #[get("/")] + /// async fn db_op(db: Connection) { + /// let inner = db.into_inner(); + /// } + /// # } + /// ``` + pub fn into_inner(self) -> ::Connection { + self.0 + } +} + #[rocket::async_trait] impl Fairing for Initializer { fn info(&self) -> Info {