Skip to content

Commit

Permalink
Add a get_kind method to Pool (#1228)
Browse files Browse the repository at this point in the history
  • Loading branch information
nitnelave authored Nov 23, 2021
1 parent 8299687 commit 5aef7d7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sqlx-core/src/any/kind.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::error::Error;
use std::str::FromStr;

#[derive(Debug, Clone, Copy)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum AnyKind {
#[cfg(feature = "postgres")]
Postgres,
Expand Down
15 changes: 14 additions & 1 deletion sqlx-core/src/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
//! [`Pool::begin`].
use self::inner::SharedPool;
#[cfg(feature = "any")]
use crate::any::{Any, AnyKind};
use crate::connection::Connection;
use crate::database::Database;
use crate::error::Error;
Expand Down Expand Up @@ -290,7 +292,7 @@ impl<DB: Database> Pool<DB> {
}
}

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

#[cfg(feature = "any")]
impl Pool<Any> {
/// Returns the database driver currently in-use by this `Pool`.
///
/// Determined by the connection URI.
#[cfg(feature = "any")]
pub fn any_kind(&self) -> AnyKind {
self.0.connect_options.kind()
}
}

/// Returns a new [Pool] tied to the same shared connection pool.
impl<DB: Database> Clone for Pool<DB> {
fn clone(&self) -> Self {
Expand Down

0 comments on commit 5aef7d7

Please sign in to comment.