Checks if a connection to the database is still valid.
(&self)
| 460 | |
| 461 | /// Checks if a connection to the database is still valid. |
| 462 | pub async fn ping(&self) -> Result<(), DbErr> { |
| 463 | match self { |
| 464 | #[cfg(feature = "sqlx-mysql")] |
| 465 | DatabaseConnection::SqlxMySqlPoolConnection(conn) => conn.ping().await, |
| 466 | #[cfg(feature = "sqlx-postgres")] |
| 467 | DatabaseConnection::SqlxPostgresPoolConnection(conn) => conn.ping().await, |
| 468 | #[cfg(feature = "sqlx-sqlite")] |
| 469 | DatabaseConnection::SqlxSqlitePoolConnection(conn) => conn.ping().await, |
| 470 | #[cfg(feature = "mock")] |
| 471 | DatabaseConnection::MockDatabaseConnection(conn) => conn.ping(), |
| 472 | #[cfg(feature = "proxy")] |
| 473 | DatabaseConnection::ProxyDatabaseConnection(conn) => conn.ping().await, |
| 474 | DatabaseConnection::Disconnected => Err(conn_err("Disconnected")), |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | /// Explicitly close the database connection. |
| 479 | /// See [`Self::close_by_ref`] for usage with references. |
nothing calls this directly
no test coverage detected