1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use futures_core::future::BoxFuture;
use crate::error::Error;
use crate::sqlite::{Sqlite, SqliteConnection};
use crate::transaction::TransactionManager;
pub struct SqliteTransactionManager;
impl TransactionManager for SqliteTransactionManager {
type Database = Sqlite;
fn begin(conn: &mut SqliteConnection) -> BoxFuture<'_, Result<(), Error>> {
Box::pin(conn.worker.begin())
}
fn commit(conn: &mut SqliteConnection) -> BoxFuture<'_, Result<(), Error>> {
Box::pin(conn.worker.commit())
}
fn rollback(conn: &mut SqliteConnection) -> BoxFuture<'_, Result<(), Error>> {
Box::pin(conn.worker.rollback())
}
fn start_rollback(conn: &mut SqliteConnection) {
conn.worker.start_rollback().ok();
}
}