diff --git a/sqlx-pool-guard/src/lib.rs b/sqlx-pool-guard/src/lib.rs index b851f1ef79..6f01b2b55c 100644 --- a/sqlx-pool-guard/src/lib.rs +++ b/sqlx-pool-guard/src/lib.rs @@ -37,21 +37,8 @@ pub struct SqlitePoolGuard { connection_pool: sqlx::SqlitePool, } -impl Deref for SqlitePoolGuard { - type Target = sqlx::SqlitePool; - - fn deref(&self) -> &Self::Target { - &self.connection_pool - } -} - -impl DerefMut for SqlitePoolGuard { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.connection_pool - } -} - impl SqlitePoolGuard { + /// Create new instance providing path to database and connection pool pub fn new(database_path: PathBuf, connection_pool: sqlx::SqlitePool) -> Self { Self { database_path, @@ -59,6 +46,11 @@ impl SqlitePoolGuard { } } + /// Returns database path + pub fn database_path(&self) -> &Path { + &self.database_path + } + /// Close udnerlying sqlite pool and wait for files to be closed before returning. pub async fn close(&self) { // Avoid waiting for db files once the pool is marked closed to ensure that we don't wait on some other sqlite pool to close the database. @@ -125,6 +117,19 @@ impl SqlitePoolGuard { } } +impl Deref for SqlitePoolGuard { + type Target = sqlx::SqlitePool; + + fn deref(&self) -> &Self::Target { + &self.connection_pool + } +} + +impl DerefMut for SqlitePoolGuard { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.connection_pool + } +} #[cfg(test)] mod tests { use sqlx::{