use crate::{
internal::{PostgreRow, SQLiteRow},
Error, Pool, PoolKind, Row,
};
pub trait Schema {
fn schema(pool: &Pool) -> &'static str {
match pool.as_kind() {
#[cfg(feature = "postgresql")]
PoolKind::PostgreSQL => Self::schema_postgres(),
#[cfg(feature = "sqlite")]
PoolKind::SQLite => Self::schema_sqlite(),
}
}
#[cfg(feature = "postgresql")]
fn schema_postgres() -> &'static str;
#[cfg(feature = "sqlite")]
fn schema_sqlite() -> &'static str;
}
pub trait Table {
fn columns() -> usize;
fn from_row(row: Row<'_>) -> Result<Self, Error>
where
Self: Sized,
{
match row {
#[cfg(feature = "postgresql")]
Row::PostgreSQL(row) => Self::from_row_postgres(row),
#[cfg(feature = "sqlite")]
Row::SQLite(row) => Self::from_row_sqlite(row),
}
}
#[cfg(feature = "postgresql")]
fn from_row_postgres(row: PostgreRow) -> Result<Self, Error>
where
Self: Sized;
#[cfg(feature = "sqlite")]
fn from_row_sqlite<'__table_row>(
row: &'__table_row SQLiteRow<'__table_row>,
) -> Result<Self, Error>
where
Self: Sized;
}