aboutsummaryrefslogtreecommitdiff
path: root/src/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/db')
-rw-r--r--src/db/backend.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/db/backend.rs b/src/db/backend.rs
index 5ae4de2..b75d5ca 100644
--- a/src/db/backend.rs
+++ b/src/db/backend.rs
@@ -1,5 +1,18 @@
-pub enum DbBackend {
- Sqlite {
- db_file: &'static str,
+pub use diesel::connection::Connection;
+
+pub trait Connectable {
+ type Connection: Connection;
+ fn connect(&self) -> diesel::ConnectionResult<Self::Connection>;
+}
+
+pub struct Sqlite {
+ pub db_file: &'static str,
+}
+
+impl Connectable for Sqlite {
+ type Connection = diesel::sqlite::SqliteConnection;
+
+ fn connect(&self) -> diesel::ConnectionResult<Self::Connection> {
+ Self::Connection::establish(self.db_file)
}
}