mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 14:34:19 +00:00
Add a get_kind
method to Pool (#1228)
This commit is contained in:
parent
8299687878
commit
5aef7d7801
2 changed files with 15 additions and 2 deletions
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue