Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a get_kind method to Pool #1228

Merged
merged 1 commit into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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