Make the database kind queryable from AnyConnectionKind and AnyConnection
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 {
