Run a fallible function in a transaction. If the supplied function returns `Ok`, the transaction is automatically committed. Otherwise, the transaction is rolled back. This method is provided for convenience, as it allows to safely use the `?` operator in code running within a transaction context. Recall that a [`MutTx`] does not follow the RAII pattern, so the following code is wrong: ```ignor
(&self, workload: Workload, f: F)
| 925 | /// })?; |
| 926 | /// ``` |
| 927 | pub fn with_auto_commit<F, A, E>(&self, workload: Workload, f: F) -> Result<A, E> |
| 928 | where |
| 929 | F: FnOnce(&mut MutTx) -> Result<A, E>, |
| 930 | E: From<DBError>, |
| 931 | { |
| 932 | let mut tx = self.begin_mut_tx(IsolationLevel::Serializable, workload); |
| 933 | let res = f(&mut tx); |
| 934 | self.finish_tx(tx, res) |
| 935 | } |
| 936 | |
| 937 | /// Run a fallible function in a transaction, rolling it back if the |
| 938 | /// function returns `Err`. |