Skip to content

Commit 5aef7d7

Browse files
authored
Add a get_kind method to Pool (#1228)
1 parent 8299687 commit 5aef7d7

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

sqlx-core/src/any/kind.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::error::Error;
22
use std::str::FromStr;
33

4-
#[derive(Debug, Clone, Copy)]
4+
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
55
pub enum AnyKind {
66
#[cfg(feature = "postgres")]
77
Postgres,

sqlx-core/src/pool/mod.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
//! [`Pool::begin`].
5656
5757
use self::inner::SharedPool;
58+
#[cfg(feature = "any")]
59+
use crate::any::{Any, AnyKind};
5860
use crate::connection::Connection;
5961
use crate::database::Database;
6062
use crate::error::Error;
@@ -290,7 +292,7 @@ impl<DB: Database> Pool<DB> {
290292
}
291293
}
292294

293-
/// Shut down the connection pool, waiting for all connections to be gracefully closed.
295+
/// Shut down the connection pool, waiting for all connections to be gracefully closed.
294296
///
295297
/// Upon `.await`ing this call, any currently waiting or subsequent calls to [Pool::acquire] and
296298
/// the like will immediately return [Error::PoolClosed] and no new connections will be opened.
@@ -337,6 +339,17 @@ impl<DB: Database> Pool<DB> {
337339
}
338340
}
339341

342+
#[cfg(feature = "any")]
343+
impl Pool<Any> {
344+
/// Returns the database driver currently in-use by this `Pool`.
345+
///
346+
/// Determined by the connection URI.
347+
#[cfg(feature = "any")]
348+
pub fn any_kind(&self) -> AnyKind {
349+
self.0.connect_options.kind()
350+
}
351+
}
352+
340353
/// Returns a new [Pool] tied to the same shared connection pool.
341354
impl<DB: Database> Clone for Pool<DB> {
342355
fn clone(&self) -> Self {

0 commit comments

Comments
 (0)