use barrel::backend::SqlGenerator; pub use diesel::connection::Connection; pub trait UsableBackend: diesel::backend::Backend where *const str: diesel::deserialize::FromSql {} impl UsableBackend for diesel::sqlite::Sqlite {} pub trait UsableConnection: Connection where ::Backend: UsableBackend {} impl UsableConnection for diesel::sqlite::SqliteConnection {} pub trait Connectable { type Connection: UsableConnection; type SqlGenerator: SqlGenerator; fn connect(&self) -> diesel::ConnectionResult; } pub struct Sqlite { pub db_file: &'static str, } impl Connectable for Sqlite { type Connection = diesel::sqlite::SqliteConnection; type SqlGenerator = barrel::backend::Sqlite; fn connect(&self) -> diesel::ConnectionResult { Self::Connection::establish(self.db_file) } }