Listening to the shaggs!

This commit is contained in:
didier amyot committed 2023-02-24 08:52:50 -05:00
1 parent 238cd9f2da
commit 9f86d53d11
9 files changed
+69 -66

No files matched your search

+4 -23
View File
@@ -17,22 +17,15 @@ pub enum Error {
pub type CustomResult<T, E = Error> = Result<T, E>;
trait SQLiteConnectionFactory {
fn connection(&self) -> Connection;
fn readonly(&self) -> Connection;
}
pub struct PathSQLiteConnectionFactory {
pub struct SQLiteConnectionFactory {
path: String,
}
impl PathSQLiteConnectionFactory {
pub fn new(path: String) -> PathSQLiteConnectionFactory {
PathSQLiteConnectionFactory { path }
impl SQLiteConnectionFactory {
pub fn new(path: String) -> SQLiteConnectionFactory {
SQLiteConnectionFactory { path }
}
}
impl SQLiteConnectionFactory for PathSQLiteConnectionFactory {
fn connection(&self) -> Connection {
Connection::open(&self.path).unwrap()
}
@@ -41,15 +34,3 @@ impl SQLiteConnectionFactory for PathSQLiteConnectionFactory {
Connection::open_with_flags(&self.path, OpenFlags::SQLITE_OPEN_READ_ONLY).unwrap()
}
}
pub struct InMemorySQLiteConnectionFactory {}
impl SQLiteConnectionFactory for InMemorySQLiteConnectionFactory {
fn connection(&self) -> Connection {
Connection::open_in_memory().unwrap()
}
fn readonly(&self) -> Connection {
Connection::open_in_memory_with_flags(OpenFlags::SQLITE_OPEN_READ_ONLY).unwrap()
}
}