(&mut self)
| 47 | } |
| 48 | |
| 49 | pub async fn begin(&mut self) -> ApplicationResult<()> { |
| 50 | match self.transaction.as_mut() { |
| 51 | None => { |
| 52 | self.transaction = Some( |
| 53 | self.pool |
| 54 | .begin() |
| 55 | .await |
| 56 | .map_err(|err| ApplicationError::DatabaseConnectionError(Box::new(err)))?, |
| 57 | ); |
| 58 | Ok(()) |
| 59 | } |
| 60 | Some(_trx) => { |
| 61 | println!("Transaction Begun Already!"); |
| 62 | Err(ApplicationError::TransactionError)? |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | pub async fn commit(&mut self) -> ApplicationResult<()> { |
| 68 | if self.transaction.is_none() { |
no outgoing calls