going somewhere.
This commit is contained in:
1 parent
494cdedfc6
commit
64e9be8b5a
12 files changed
+203
-76
No files matched your search
+23
@@ -0,0 +1,23 @@
|
||||
use rusqlite::{Params, Transaction};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
SqlError(rusqlite::Error),
|
||||
InvalidDrawer(String),
|
||||
}
|
||||
|
||||
pub type CustomResult<T, E = Error> = Result<T, E>;
|
||||
|
||||
pub struct TransactionHelper<'a> {
|
||||
tx: &'a Transaction<'a>,
|
||||
}
|
||||
|
||||
impl TransactionHelper<'_> {
|
||||
pub fn new<'a>(tx: &'a Transaction) -> TransactionHelper<'a> {
|
||||
TransactionHelper { tx }
|
||||
}
|
||||
|
||||
pub fn execute<P: Params>(&self, sql: &str, params: P) -> CustomResult<usize> {
|
||||
self.tx.execute(sql, params).map_err(Error::SqlError)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user