Make the database kind queryable from AnyConnectionKind and AnyConnection (#1592)

This commit is contained in:
05storm26 2021-12-29 02:19:26 +01:00 committed by GitHub
parent d258e8c681
commit beb2100f29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
use futures_core::future::BoxFuture;
use crate::any::{Any, AnyConnectOptions};
use crate::any::{Any, AnyConnectOptions, AnyKind};
use crate::connection::Connection;
use crate::error::Error;
@ -47,6 +47,30 @@ pub(crate) enum AnyConnectionKind {
Sqlite(sqlite::SqliteConnection),
}
impl AnyConnectionKind {
pub fn kind(&self) -> AnyKind {
match self {
#[cfg(feature = "postgres")]
AnyConnectionKind::Postgres(_) => AnyKind::Postgres,
#[cfg(feature = "mysql")]
AnyConnectionKind::MySql(_) => AnyKind::MySql,
#[cfg(feature = "sqlite")]
AnyConnectionKind::Sqlite(_) => AnyKind::Sqlite,
#[cfg(feature = "mssql")]
AnyConnectionKind::Mssql(_) => AnyKind::Mssql,
}
}
}
impl AnyConnection {
pub fn kind(&self) -> AnyKind {
self.0.kind()
}
}
macro_rules! delegate_to {
($self:ident.$method:ident($($arg:ident),*)) => {
match &$self.0 {