pub struct Transaction<'a, K, V>{ /* private fields */ }Implementations§
Source§impl<'a, K, V> Transaction<'a, K, V>
impl<'a, K, V> Transaction<'a, K, V>
Sourcepub fn commit(self) -> IsamResult<()>
pub fn commit(self) -> IsamResult<()>
Flush store and index to disk (fsync) and release the database lock.
After commit returns the changes are durable and the lock is released,
allowing other threads to begin their own transactions.
§Example
let mut txn = db.begin_transaction().unwrap();
db.insert(&mut txn, 1u32, &"hello".to_string()).unwrap();
txn.commit().unwrap();
// Data is now durable — visible after reopen.
let db2: Isam<u32, String> = Isam::open(&path).unwrap();
let mut txn2 = db2.begin_transaction().unwrap();
assert_eq!(db2.get(&mut txn2, &1u32).unwrap(), Some("hello".to_string()));
txn2.commit().unwrap();Sourcepub fn rollback(self) -> IsamResult<()>
pub fn rollback(self) -> IsamResult<()>
Roll back all changes made in this transaction and release the lock.
The undo log is applied in reverse order, restoring the index to the
state it had before the transaction began. Dropping a Transaction
without calling commit has the same effect automatically.
§Example
let mut txn = db.begin_transaction().unwrap();
db.insert(&mut txn, 1u32, &"oops".to_string()).unwrap();
txn.rollback().unwrap();
// Insert was rolled back — key is absent.
let mut txn2 = db.begin_transaction().unwrap();
assert_eq!(db.get(&mut txn2, &1u32).unwrap(), None);
txn2.commit().unwrap();Trait Implementations§
Source§impl<'a, K, V> Drop for Transaction<'a, K, V>
impl<'a, K, V> Drop for Transaction<'a, K, V>
Auto Trait Implementations§
impl<'a, K, V> Freeze for Transaction<'a, K, V>
impl<'a, K, V> RefUnwindSafe for Transaction<'a, K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<'a, K, V> !Send for Transaction<'a, K, V>
impl<'a, K, V> !Sync for Transaction<'a, K, V>
impl<'a, K, V> Unpin for Transaction<'a, K, V>
impl<'a, K, V> UnwindSafe for Transaction<'a, K, V>where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more