use std::marker::PhantomData;
#[cfg(feature = "sqlite")]
use std::sync::Arc;
pub enum StreamConnection<'a> {
#[cfg(feature = "sqlite")]
Sqlite(Arc<turso::Connection>),
#[cfg(feature = "postgresql")]
PostgreSQL(&'a tokio_postgres::Client),
#[cfg(feature = "mysql")]
MySQL(mysql_async::Conn),
#[cfg(feature = "mssql")]
MSSQL(&'a tiberius::Client<tokio_util::compat::Compat<tokio::net::TcpStream>>),
#[doc(hidden)]
__Lifetime(PhantomData<&'a ()>),
}
impl<'a> StreamConnection<'a> {
#[cfg(feature = "sqlite")]
pub fn expect_sqlite(&self) -> &Arc<turso::Connection> {
match self {
StreamConnection::Sqlite(conn) => conn,
_ => unreachable!("Expected Sqlite connection"),
}
}
#[cfg(feature = "postgresql")]
pub fn expect_postgresql(&self) -> &&'a tokio_postgres::Client {
match self {
StreamConnection::PostgreSQL(client) => client,
_ => unreachable!("Expected PostgreSQL connection"),
}
}
}
impl<'a> Drop for StreamConnection<'a> {
fn drop(&mut self) {
match self {
#[cfg(feature = "sqlite")]
StreamConnection::Sqlite(_) => {
}
#[cfg(feature = "postgresql")]
StreamConnection::PostgreSQL(_) => {
}
#[cfg(feature = "mysql")]
StreamConnection::MySQL(conn) => {
let _ = conn;
}
#[cfg(feature = "mssql")]
StreamConnection::MSSQL(_) => {
}
StreamConnection::__Lifetime(_) => {}
}
}
}