Skip to content

Commit 183e620

Browse files
author
Andrew Wheeler(Genusis)
authored
Implement From for AnyConnection (#1652)
* Implemented From for AnyConnection to cover the 4 Database type connections to AnyConnection * formatting
1 parent e7a50d3 commit 183e620

File tree

1 file changed

+28
-0
lines changed
  • sqlx-core/src/any/connection

1 file changed

+28
-0
lines changed

sqlx-core/src/any/connection/mod.rs

+28
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,31 @@ impl Connection for AnyConnection {
183183
delegate_to!(self.should_flush())
184184
}
185185
}
186+
187+
#[cfg(feature = "postgres")]
188+
impl From<postgres::PgConnection> for AnyConnection {
189+
fn from(conn: postgres::PgConnection) -> Self {
190+
AnyConnection(AnyConnectionKind::Postgres(conn))
191+
}
192+
}
193+
194+
#[cfg(feature = "mssql")]
195+
impl From<mssql::MssqlConnection> for AnyConnection {
196+
fn from(conn: mssql::MssqlConnection) -> Self {
197+
AnyConnection(AnyConnectionKind::Mssql(conn))
198+
}
199+
}
200+
201+
#[cfg(feature = "mysql")]
202+
impl From<mysql::MySqlConnection> for AnyConnection {
203+
fn from(conn: mysql::MySqlConnection) -> Self {
204+
AnyConnection(AnyConnectionKind::MySql(conn))
205+
}
206+
}
207+
208+
#[cfg(feature = "sqlite")]
209+
impl From<sqlite::SqliteConnection> for AnyConnection {
210+
fn from(conn: sqlite::SqliteConnection) -> Self {
211+
AnyConnection(AnyConnectionKind::Sqlite(conn))
212+
}
213+
}

0 commit comments

Comments
 (0)