Implement From for AnyConnection (#1652)

* Implemented From for AnyConnection to cover the 4 Database type connections to AnyConnection

* formatting
This commit is contained in:
Andrew Wheeler(Genusis) 2022-02-16 21:59:32 -05:00 committed by GitHub
parent e7a50d3501
commit 183e620381
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -183,3 +183,31 @@ impl Connection for AnyConnection {
delegate_to!(self.should_flush())
}
}
#[cfg(feature = "postgres")]
impl From<postgres::PgConnection> for AnyConnection {
fn from(conn: postgres::PgConnection) -> Self {
AnyConnection(AnyConnectionKind::Postgres(conn))
}
}
#[cfg(feature = "mssql")]
impl From<mssql::MssqlConnection> for AnyConnection {
fn from(conn: mssql::MssqlConnection) -> Self {
AnyConnection(AnyConnectionKind::Mssql(conn))
}
}
#[cfg(feature = "mysql")]
impl From<mysql::MySqlConnection> for AnyConnection {
fn from(conn: mysql::MySqlConnection) -> Self {
AnyConnection(AnyConnectionKind::MySql(conn))
}
}
#[cfg(feature = "sqlite")]
impl From<sqlite::SqliteConnection> for AnyConnection {
fn from(conn: sqlite::SqliteConnection) -> Self {
AnyConnection(AnyConnectionKind::Sqlite(conn))
}
}