pub struct Transaction { /* private fields */ }Expand description
A serializable snapshot isolated database transaction.
All mutations are buffered in-memory. On commit() they are flushed to
IndexedDB in a single synchronous batch so that the IDB transaction never
goes idle between requests.
Implementations§
Source§impl Transaction
impl Transaction
pub fn closed(&self) -> bool
pub async fn cancel(&mut self) -> Result<(), Error>
Sourcepub async fn commit(&mut self) -> Result<(), Error>
pub async fn commit(&mut self) -> Result<(), Error>
Commit: flush all buffered writes to IndexedDB in one atomic batch.
Opens a fresh read-write IDB transaction. Puts are batched via
put_all (all IDB requests fired synchronously, only the last
awaited). Deletes are issued sequentially – each await is safe
because the next delete() call is queued in the same microtask
as the previous request’s completion, keeping the transaction alive.
pub async fn exists(&self, key: Key) -> Result<bool, Error>
pub async fn get(&self, key: Key) -> Result<Option<Val>, Error>
pub async fn set(&mut self, key: Key, val: Val) -> Result<(), Error>
pub async fn put(&mut self, key: Key, val: Val) -> Result<(), Error>
pub async fn putc( &mut self, key: Key, val: Val, chk: Option<Val>, ) -> Result<(), Error>
pub async fn del(&mut self, key: Key) -> Result<(), Error>
pub async fn delc(&mut self, key: Key, chk: Option<Val>) -> Result<(), Error>
pub async fn keys(&self, rng: Range<Key>, limit: u32) -> Result<Vec<Key>, Error>
pub async fn keysr( &self, rng: Range<Key>, limit: u32, ) -> Result<Vec<Key>, Error>
pub async fn scan( &self, rng: Range<Key>, limit: u32, ) -> Result<Vec<(Key, Val)>, Error>
pub async fn scanr( &self, rng: Range<Key>, limit: u32, ) -> Result<Vec<(Key, Val)>, Error>
pub async fn set_savepoint(&mut self) -> Result<(), Error>
Sourcepub async fn rollback_to_savepoint(&mut self) -> Result<(), Error>
pub async fn rollback_to_savepoint(&mut self) -> Result<(), Error>
Rollback to the most recent savepoint by replaying undo operations against the in-memory buffer. No IDB calls needed.
Auto Trait Implementations§
impl Freeze for Transaction
impl !RefUnwindSafe for Transaction
impl !Send for Transaction
impl !Sync for Transaction
impl Unpin for Transaction
impl UnsafeUnpin for Transaction
impl !UnwindSafe for Transaction
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